Certbot Renewal Failed on Ubuntu? How to Fix It
The first sign of a failed Certbot renewal is usually a browser warning. The reason is already written down in a log, and reading it beats guessing.
When Certbot renewal fails on an Ubuntu server, you usually find out from a browser warning, because the scheduled job that should have renewed the certificate failed quietly weeks earlier. The reassuring part is that Certbot records exactly why it failed. The work is reading that reason instead of guessing at firewalls.
Read the actual error first
Start with a dry run. It exercises the same code path as a real renewal, including the authenticator saved for each certificate, without touching your live files.
sudo certbot renew --dry-run
Certbot keeps its status logs in /var/log/letsencrypt. The newest entries contain the full error from Let's Encrypt, which is more detailed than what the dry run prints.
sudo tail -n 80 /var/log/letsencrypt/letsencrypt.log
sudo certbot certificates
certbot certificates lists every certificate by name with its domains and expiry date. Compare that list with the sites you actually serve, because a certificate that was issued once by hand and never added to a renewal configuration will not appear.
| Message in the log | Usually means |
|---|---|
| Timeout during connect (likely firewall problem) | Port 80 is not reachable from the internet, or the domain points at another machine |
| Connection refused | Nothing is listening on port 80 at that address, or the web server is down |
| Invalid response ... 404 for the acme-challenge URL | The web server answers but is not serving the challenge file from the folder Certbot wrote it to |
| DNS problem: NXDOMAIN looking up A for ... | A hostname in the certificate no longer exists in DNS, often an old www or subdomain |
Check that renewal is scheduled at all
Certbot's documentation says automatic renewal is normally pre-configured as a scheduled task running certbot renew, either a cron entry or a systemd timer. See which one your server has.
systemctl list-timers 'certbot*' 'snap.certbot*'
which -a certbot
On Ubuntu it is common to find two copies of Certbot, one from apt and one from the snap, both pointing at the same /etc/letsencrypt directory. Pick one and remove the other, because two installs with two timers make every failure harder to read. The snap's timer is named snap.certbot.renew.timer.
Fix the usual challenge failures
Most failures come from the HTTP-01 challenge, where Let's Encrypt fetches a token file from http://your-domain/.well-known/acme-challenge/ over port 80. Work through these in order.
-
1
Is port 80 open and answered by nginx?
sudo ss -ltnp | grep ':80 'shows what is listening, andsudo ufw statusshows whether the firewall allows it. Test from another machine, not from the server itself, because a local request proves nothing about the internet path. -
2
Does DNS point at this server, over IPv4 and IPv6?
Run
dig +short A example.comanddig +short AAAA example.com. A stale AAAA record is a classic cause, since the validation request may go to an IPv6 address that no longer leads to this server. -
3
Does the saved renewal configuration use the right authenticator?
Each certificate has a file at
/etc/letsencrypt/renewal/NAME.conf. If itsauthenticatorisstandalone, Certbot wants port 80 for itself, which fails whenever nginx is already running. -
4
Is a rule in nginx blocking the challenge path?
A catch-all redirect to another host, or a dotfile rule such as
location ~ /\. { deny all; }, will stop Let's Encrypt from reading.well-known. Add an explicit exception for the challenge path above those rules. -
5
Are you hitting the failure limit?
After five failed validations in an hour for the same hostname, Let's Encrypt refuses new orders until the allowance refills. Debug with
--dry-runonly, then run one real renewal when the dry run passes.
sudo grep -E 'authenticator|installer|webroot' /etc/letsencrypt/renewal/example.com.conf
location ^~ /.well-known/acme-challenge/ {
root /var/www/example;
default_type text/plain;
}
If the authenticator is wrong, re-issue the settings with the method you actually want. Certbot saves the options you used for each certificate, so running it once with the correct plugin replaces the old ones. Back up the renewal file first, because Certbot's own documentation warns that hand-editing these files can damage them.
sudo cp /etc/letsencrypt/renewal/example.com.conf /root/example.com.conf.bak
sudo certbot certonly --webroot -w /var/www/example -d example.com -d www.example.com --cert-name example.com
sudo certbot renew --dry-run
Make nginx load the new certificate
Certbot can renew successfully and your visitors still see the old certificate, because nginx keeps the previous one in memory until it reloads. Certbot runs executable scripts from /etc/letsencrypt/renewal-hooks/deploy only after a successful renewal, which makes that directory the right place for a reload.
sudo tee /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh >/dev/null <<'EOF'
#!/bin/sh
systemctl reload nginx
EOF
sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
One detail catches people during testing: a dry run does not run deploy hooks unless you add --run-deploy-hooks. A hook that looks untested after a dry run has not necessarily failed.
Checking each server's timer, renewal file and served certificate by hand is quick once and tedious across a fleet. BashPilot can run those checks as one request on every Ubuntu server you manage. It reads the renewal log, timers and certificate expiry first, asks for approval before it changes renewal settings or reloads a service, and checks the result afterwards. The related disk and CPU checks in Why Is My Linux Server CPU at 100%? follow the same read-first approach.
Checking certificate renewal on two servers
Read-only check done. web01 is healthy. On web02 the certificate has 11 days left, and its renewal file uses the standalone authenticator while nginx is running on port 80, which will fail.
| Server | Days left | Timer | Authenticator |
|---|---|---|---|
| web01 | 52 | active | webroot |
| web02 | 11 | active | standalone |
This changes the renewal settings for example.com on web02. Confirm and I will run it, then do a dry run to prove the renewal works.
certbot certonly --webroot -w /var/www/example -d example.com --cert-name example.com
certbot renew --dry-run
Try this on one of your own servers.
Start free trialProve the fix worked
sudo certbot renew --dry-runfinishes with every certificate listed as a success.systemctl list-timers 'certbot*' 'snap.certbot*'shows a next run time in the near future.- After the next real renewal,
sudo certbot certificatesshows a new expiry date, and the certificate nginx serves matches it.
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates
Stop it failing silently again
Renewal depends on a timer, a reachable port, a correct authenticator and a reload. Any one of them can break months after you set it up. Add a check that does not depend on Certbot at all, so a silent failure becomes a visible one.
openssl x509 -checkend 1209600 -noout -in /etc/letsencrypt/live/example.com/fullchain.pem
Run that from cron or your monitoring system and alert on a non-zero exit. Then the next failed renewal reaches you two weeks before visitors see a warning, instead of the morning someone reports the site as insecure.