Expired certs - auto-renew or manual

I have SNAP version of certbot installed with auto renew on ubuntu 22.04 LTS. Due to some issues with systemd / init, i'm running nginx as process, due to this "snap application certbot.renew" have crashed/failed to renew certificates automatically.

When running "certbot certonly --force-renew" it is asking "Are you trying to change the key type of the certificate named <<removed-domain>>-0001 from ECDSA to RSA? Please provide both --cert-name and --key-type on the command line to confirm the change you are trying to make."

Question.

1, Is there anyway to re-enable auto-renew for expired certs ?.
2, If only manual renewal is possible, what additional commands i need to pass for successful renewal.

Thanks.

My domain is:

I ran this command:

sudo certbot certificates

It produced this output:

Found the following certs:
  Certificate Name: <<removed>>-0001
    Serial Number: 529dd4a75ea30b7d03a41ec3aad78b5f852
    Key Type: ECDSA
    Domains: <<removed>>
    Expiry Date: 2026-04-09 16:26:02+00:00 (INVALID: EXPIRED)
    Certificate Path: /etc/letsencrypt/live/<<removed>>-0001/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/<<removed>>-0001/privkey.pem
  Certificate Name: <<removed>>
    Serial Number: 5d97181960be7233a43230b4d66cd33c850
    Key Type: ECDSA
    Domains: <<removed>> www.<<removed>>
    Expiry Date: 2026-04-07 11:06:12+00:00 (INVALID: EXPIRED)
    Certificate Path: /etc/letsencrypt/live/<<removed>>/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/<<removed>>/privkey.pem

My web server is (include version):

nginx/1.18.0 (Ubuntu)

The operating system my web server runs on is (include version):

Ubuntu 22.04.5 LTS

I can login to a root shell on my machine (yes or no, or I don't know):

Yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel):

No

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot):

certbot 5.5 SNAP version. and certbot 1.21.0

Sure, but not sure what problem you had originally. First, does the snap version of Certbot work? Why do you also have the apt version? Anyway, what does this show:

sudo certbot --version

And this

sudo certbot renew --dry-run

Pick one, and remove the other.
[I'd pick the SNAP version]

~$ sudo certbot --version
certbot 1.21.0

~$ sudo certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/<<removed>>-0001.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simulating renewal of an existing certificate for <<removed>>

Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
  Domain: <<removed>>
  Type:   connection
  Detail: <<public-IP>>: Fetching http://<<removed>>/.well-known/acme-challenge/GjHH7L9hXIrXUntrM_buF_bIiOvfzSHpqoUT_QPkyUc: Timeout during connect (likely firewall problem)

Hint: The Certificate Authority failed to verify the temporary nginx configuration changes made by Certbot. Ensure the listed domains point to this nginx server and that it is accessible from the internet.

Failed to renew certificate <<removed>>-0001 with error: Some challenges have failed.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/<<removed>>.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simulating renewal of an existing certificate for <<removed>> and www.<<removed>>

Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
  Domain: <<removed>>
  Type:   connection
  Detail: <<public-IP>>: Fetching http://<<removed>>/.well-known/acme-challenge/fIeMli5mhcnv5jycqYUXTR-LxKV95MF6nBrxIfqd9oE: Timeout during connect (likely firewall problem)

  Domain: www.<<removed>>
  Type:   connection
  Detail: <<public-IP>>: Fetching http://www.<<removed>>/.well-known/acme-challenge/qwBIsyh2phSeilg7INjz1KmK4j-8OzbTWC-0rd562DY: Timeout during connect (likely firewall problem)

Hint: The Certificate Authority failed to verify the temporary nginx configuration changes made by Certbot. Ensure the listed domains point to this nginx server and that it is accessible from the internet.

Failed to renew certificate <<removed>> with error: Some challenges have failed.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
All simulated renewals failed. The following certificates could not be renewed:
  /etc/letsencrypt/live/<<removed>>-0001/fullchain.pem (failure)
  /etc/letsencrypt/live/<<removed>>/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Hook 'post-hook' reported error code 1
Hook 'post-hook' ran with error output:
 Job for nginx.service failed because the control process exited with error code.
 See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
2 renew failure(s), 0 parse failure(s)
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

Server have full internet access.

Now that i have uninstalled apt version, what to do ?.

Based on the above it looks like you removed the snap version (5.5). Or, do you mean you now also removed v1.21 ? In the end you should be using only the snap version.

As for what to do ... the error message saying "timeout" is pretty clear that Let's Encrypt's servers cannot reach your server.

You will need to find out why those HTTP requests from LE to you are timing out. Two tools we commonly use for testing connections are https://letsdebug.net and the HTTP test at Check website performance and response : Check host - online website monitoring (not its ping and not udp, the http test). Both of those sites should show successful connections if your locals comms and server are setup right. Right now both of those probably fail just like Let's Encrypt.

The most common reason is that a firewall is blocking connections. But, many other things can cause that. Without your actual domain name or more details of your setup there isn't much more specific that we can say. Keep using those testing tools until you get successful connections and retry the cert --dry-run. If that works then try getting a fresh production cert.

Can you even reach your domain from outside your local network? Like a mobile phone with wifi disabled?

Did you uninstall that?

Yes, uninstalled the APT version. Only the SNAP Auto-Renew version is there.

Check Host from Server hosted country is working.

letsdebug.net still show "ANotWorking".

Quick question, would Geo-restricting ingress traffic prevent automatic certificate renewal ?.

Yes, it can. Let's Encrypt checks from (currently) 5 different locations around the world. You are using the --nginx option of Certbot which uses the HTTP Challenge. Can you change your firewall to allow inbound requests using HTTP on port 80 with this format:
http://(domain)/.well-known/acme-challenge/(token)

Other options include using the Cerbot --pre-hook and --post-hook to open/close your firewall for port 80 when a cert request is made. Or, switch to using a DNS Challenge. Your DNS Servers still need to be accessed from all Let's Encrypt locations but at least it is not your nginx web server. See: https://letsencrypt.org/docs/challenge-types/

Your system and Certbot are not the ones used to perform the validation. As noted above, it is the Let's Encrypt ACME Servers that perform the validation and issue the cert once proven valid. Certbot is the ACME Client which makes the cert request and retrieves the cert when issued.

Now after removing geo-restriction, i'm getting "All OK!" from letsdebug.net

Now what ?.

"snap.certbot.renew.timer" service will trigger in another 2hrs.

Try this as test. If works re-run without --dry-run to get cert now or wait 2H and check auto renew works

~$ sudo certbot --version
certbot 5.5.0

~$ sudo certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
No simulated renewals were attempted.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

~$ sudo certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
No certificates found.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

It's all bit strange, after uninstalling APT version(not purged), above is the output !!!. Now, i don't have /etc/letsencrypt/live/ and the .pem files have vanished.

I'm certain the auto-rewals were triggered by the SNAP version as i don't have crontab entry for auto-renewals.

That is very strange. Are you using containers or VMs? Because normally the /etc/letsencrypt directory is not affected by install/uninstall

Your nginx config may now also be damaged. Your nginx config refers to the certificate files which now appear missing. If you try to stop/start/restart nginx it will likely fail.

Show result of this. It won't affect your running nginx but will identify this error, if true.
sudo nginx -t

If you use a different nginx command then use that. I wasn't sure what you meant in your first post by running nginx as "process" because of systemd troubles.

It is a VM. It is very strange and have looked whether anyone have ran "apt purge" in history.

~$ sudo nginx -t
nginx: [emerg] open() "/etc/letsencrypt/options-ssl-nginx.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/<<removed>>.conf:19
nginx: configuration file /etc/nginx/nginx.conf test failed

What would be the correct method ?

Retrieve certificates from crt.sh and place it in /etc/letsencrypt/live/ and run Renew commands ?.

or

Reissue the certificates with sudo certbot --nginx -d yourdomain.com ?.

Yes, your nginx is now broken. You will need to manually update its config to remove all references to the non-existent files. Restoring the missing /etc/letsencrypt from backup (or your entire system) would be easiest. Or review this section of docs: User Guide — Certbot 5.6.0.dev0 documentation

No, that won't work. While you can retrieve the cert from there you cannot retrieve the private key which was only ever on your system. Plus, recreating the /etc/letsencrypt directories by hand is very difficult and involves symlinks and coordinating with the renewal config file. You should not try to do that manually.

That will not work either. That method requires a working nginx server but yours is currently broken. We may be able to create a cert using a different method. Then, if that works we then reconfigure your system to use a method that is automated properly. But, this takes a fair amount of time and effort. Your system does not behave in the usual way so I don't have high confidence this would even work for you.

Your best approach is to fix your broken nginx so that sudo nginx -t works and then get fresh cert using sudo certbot --nginx ...

After restoring missing files(certbot related) from github and commenting out previous certbot references in nginix configuration, it downloaded certs for the domain.

Question - Can i re-enable geo-restriction ?. or need to disable it for cert renewal ?.

See FAQ.

the source country of the validation may change at any time.

so for renewal you would need to disable the geo block

other CAs do the same as it is a requirement by CA/B Forum

Ideally you'd exempt the /.well-known/acme-challenge/ path from the geoblock.

Just reminding of my prior comment

There is a new type of challenge called dns-persist-01. It allows you to set a TXT record in your DNS once and satisfy challenges as long as you wish. It is currently in Staging for Let's Encrypt with hoped for production this quarter. I have not seen any announcement on how quickly the EFF will update Certbot to support this challenge though.

Like the existing dns-01 challenge this new challenge does not require HTTP requests from LE to your server. However, if your authoritative DNS servers are behind this same firewall this new challenge won't help. Often DNS Servers are available worldwide anyway though.

See also this post: