Let's Encrypt renewal failed: how to debug certbot and renew in time

Why certbot renewals fail, from blocked port 80 to DNS and rate limits, how to read the logs, test with a dry run, and get warned before the certificate expires.

· 7 min read · By the Spot Downtime team

Let's Encrypt certificates are valid for 90 days, and certbot is meant to renew them quietly in the background. When it stops working, nobody notices for weeks. Then the certificate expires and visitors see a browser warning. This guide covers how to find out why a renewal failed and how to fix the usual causes.

If the certificate has already expired, start with SSL certificate expired to get the site back, then return here to fix the cause.

Step 1: see what certbot says

sudo certbot certificates
sudo certbot renew --dry-run
sudo tail -n 100 /var/log/letsencrypt/letsencrypt.log

The first command lists each certificate and its expiry date. The dry run goes through the full renewal against Let's Encrypt's staging servers without replacing anything and without counting against production rate limits. The log has the exact error. Look for the line that starts with Challenge failed or an HTTP status from the validation request.

Step 2: check that renewal is scheduled

Package installs usually set up a systemd timer or a cron entry. Check that it exists and ran:

systemctl list-timers | grep certbot
journalctl -u certbot.service --since "30 days ago"
ls /etc/cron.d/certbot

If nothing is scheduled (common with snap, Docker or manual installs), add it. Certbot only renews certificates within 30 days of expiry, so running twice a day is safe:

0 3,15 * * * root certbot renew --quiet --deploy-hook "systemctl reload nginx"

Common causes

Port 80 is blocked or redirected badly

The HTTP-01 challenge fetches http://your-domain/.well-known/acme-challenge/<token> over plain HTTP on port 80. A firewall or security group that only allows 443 breaks it. So does a redirect rule that sends every request, challenge included, somewhere that fails. Redirecting to HTTPS on the same host is fine, but redirecting to a different host or an app that returns 404 is not.

# Test from outside your network
curl -I http://example.com/.well-known/acme-challenge/test

# Is something listening on 80?
sudo ss -ltnp | grep ':80'

The port checker shows whether port 80 is reachable from the internet.

The web server config changed

The webroot method needs the server to serve files from the directory certbot writes to. If a config change removed the .well-known location, or a catch-all rule now captures it, validation returns 404:

# nginx
location /.well-known/acme-challenge/ {
    root /var/www/letsencrypt;
}

Match the path with the webroot_path in /etc/letsencrypt/renewal/example.com.conf.

Standalone mode and a busy port

With --standalone, certbot starts its own temporary server on port 80. If nginx or Apache is already using the port, it fails with "Address already in use". Switch to the webroot or nginx/apache plugin, or add pre and post hooks that stop and start the web server.

DNS points somewhere else

Validation connects to whatever your domain's DNS says. If the A or AAAA record now points at a different server, or an old AAAA record points at a machine that is not configured, Let's Encrypt checks the wrong place. Verify what the world sees with dig example.com A AAAA +short or the DNS record lookup. A forgotten AAAA record is a frequent culprit, because Let's Encrypt prefers IPv6 when it exists.

DNS-01 challenge and wildcard certificates

Wildcard certificates require a DNS challenge: certbot must create a TXT record at _acme-challenge.example.com. Renewals fail when the DNS plugin's API token expired or lost permissions, when the provider is slow to publish, or when a CNAME for _acme-challenge blocks the TXT record. Check the plugin credentials and look at the record while the challenge runs:

dig TXT _acme-challenge.example.com +short

Rate limits

Let's Encrypt limits repeated failed validations and repeated issuance for the same names. If you tried many times while debugging, you may be told to wait. Switch to --dry-run or the staging environment while you experiment. The limits are documented by Let's Encrypt, and they change occasionally, so check their current page rather than relying on remembered numbers.

Renewed, but the server still serves the old certificate

Certbot can renew files on disk while nginx, Apache or a proxy keeps the old certificate in memory. The server must reload. Use a deploy hook, which runs only after a successful renewal:

sudo certbot renew --deploy-hook "systemctl reload nginx"

# Or set it permanently in the renewal config
# /etc/letsencrypt/renewal/example.com.conf
# [renewalparams]
# renew_hook = systemctl reload nginx

To see what the server actually presents, run:

echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates

Or use the SSL checker. If you serve several sites, make sure each name appears in the right certificate, otherwise visitors get a name mismatch error.

Load balancers, CDNs and containers

  • Behind a load balancer, the challenge request may reach a different node than the one running certbot.
  • Behind a CDN or proxy, make sure the challenge path is passed through to the origin.
  • In Docker, renewed files must be on a volume that persists and that the web server container can read.
  • Managed platforms often handle certificates for you. Check there before running certbot on the origin.

A recovery checklist

  1. Run certbot renew --dry-run and read the error.
  2. Fix the cause: port 80, web server config, DNS or credentials.
  3. Repeat the dry run until it passes.
  4. Run sudo certbot renew --force-renewal only if you need a new certificate now. Avoid it in a loop, because it uses issuance quota.
  5. Reload the web server and confirm the new expiry date from outside.

Do not rely on email reminders alone

Let's Encrypt has stopped sending expiry reminder emails, so you cannot count on one arriving. Treat monitoring as the safety net behind automation.

Get warned before it matters

Automation fails silently, so check the result from the outside. Spot Downtime records the certificate expiry on every HTTPS website and API monitor and warns you 14, 7 and 1 day before it expires. A certificate that renews on schedule never triggers a warning, because certbot renews at 30 days. A warning at 14 days therefore means renewal did not happen, which leaves you two weeks to fix it. See SSL certificate monitoring for details, and the alerts page for where the warnings can be sent.

SSL checkerCheck a certificate's expiry date, issuer and chain from the outside.

Get new guides by email

Practical posts on monitoring, outages, error fixes and on-call, when they're published. No spam.

Unsubscribe from any email with one click. See our privacy policy.

Keep reading