Sub topic 15
Troubleshooting common failures
This chapter covers the failures you are most likely to meet when you obtain or renew a Let's Encrypt certificate with Certbot and nginx. It assumes you can use a Linux shell with sudo, read nginx configuration, query DNS records, and inspect systemd services and timers. It also assumes you have already issued at least one certificate, so the file layout under /etc/letsencrypt is familiar.
A method for diagnosing failures
Most failures fall into one of three places: validation (Let's Encrypt cannot confirm you control the domain), configuration (nginx serves the wrong thing or fails to reload), and renewal (the job does not run, or runs and fails quietly). Work from the outside in.
- Read the exact error message. Certbot prints the failing domain, the challenge type, and often the HTTP status or DNS result that Let's Encrypt saw.
- Read the log at
/var/log/letsencrypt/letsencrypt.log. It holds the full ACME exchange and the stack trace for any crash. - Reproduce what the validation server sees, from a machine outside your network.
- Fix one thing, then test with
--dry-runor--stagingso you do not use up production rate limits.
sudo tail -n 50 /var/log/letsencrypt/letsencrypt.log
sudo certbot certificatesThe second command lists each certificate lineage, its domains, and its expiry date. It also flags a certificate whose date has passed as INVALID: EXPIRED.
Validation failures
Timeout or connection refused on HTTP-01
A typical message is Timeout during connect (likely firewall problem) or Connection refused. Let's Encrypt connects to port 80 on the address your domain resolves to. If nothing answers, validation fails.
Check these in order:
- The firewall or cloud security group allows inbound TCP 80 and 443. Check
sudo ufw statusor your provider's security rules. - nginx is running and listening on port 80:
sudo ss -tlnp | grep ':80'. - Your DNS record points at this server, not at an old address.
- A router or NAT device forwards port 80 to the server, if the server is not directly on a public address.
Let's Encrypt validates from several network locations, so a firewall that blocks some regions or cloud ranges can cause intermittent failures. Do not restrict port 80 to a fixed list of source addresses.
Wrong DNS records, including AAAA
If a domain has an AAAA (IPv6) record, Let's Encrypt prefers IPv6 and tries it first. A stale or unreachable AAAA record is a frequent cause of failure when the A record is correct. Compare both:
dig +short A example.com
dig +short AAAA example.com
curl -4 -I http://example.com/
curl -6 -I http://example.com/If the IPv6 request fails, either fix the IPv6 listener (listen [::]:80; in nginx plus a firewall rule for IPv6) or remove the AAAA record. Also confirm the www name has its own record if you requested it with -d www.example.com. Every name on the certificate must validate, and one failing name fails the whole request.
404 or unexpected response on the challenge file
For HTTP-01, Let's Encrypt fetches http://example.com/.well-known/acme-challenge/<token>. Errors such as Invalid response ... 404 or Invalid response ... 301 mean another part of your configuration answered first. Common causes:
- A redirect to HTTPS that points at a broken HTTPS site. Redirecting HTTP to HTTPS is fine when the HTTPS side responds, but a redirect to a host that fails validation will fail too.
- A
locationblock that denies dotfiles, such aslocation ~ /\. { deny all; }, which also blocks/.well-known/. - A different
serverblock, often the default, catching the request becauseserver_namedoes not match.
Test with a temporary file:
sudo mkdir -p /var/www/html/.well-known/acme-challenge
echo ok | sudo tee /var/www/html/.well-known/acme-challenge/test >/dev/null
curl -i http://example.com/.well-known/acme-challenge/testIf the file does not return ok, fix nginx before you try Certbot again. With certonly --nginx, the plugin answers the challenge itself by editing the configuration temporarily, so a configuration that does not pass nginx -t will also stop it.
DNS-01 failures
For DNS-01, the error usually reads DNS problem: NXDOMAIN looking up TXT for _acme-challenge.example.com or Incorrect TXT record. Query the record directly:
dig +short TXT _acme-challenge.example.com
dig +short TXT _acme-challenge.example.com @8.8.8.8Common causes are a record that has not propagated, the record added at the wrong name (for a wildcard, the name is still _acme-challenge.example.com), and a stale record from an earlier attempt. Multiple TXT values at the same name are allowed. Wait for the authoritative name servers to return the value before pressing Enter in manual mode.
Rate limits
Let's Encrypt limits how many certificates, failed validations, and duplicate certificates you can request in a given period. The error message names the limit and the time when you can retry, for example too many failed authorizations recently or too many certificates (5) already issued for this exact set of identifiers. Check the current numbers in the Let's Encrypt rate limit documentation, because they change.
To avoid hitting them:
- Test every new setup with
--stagingfirst. Staging limits are much higher, but staging certificates are not trusted by browsers. - Use
--dry-runfor renewal tests. It uses the staging environment. - Do not delete and re-request a certificate repeatedly. Fix the cause of the failure, then request once.
If you are blocked, wait until the retry time in the message. Do not keep retrying, because failed attempts count against the failed-validation limit.
Configuration failures
nginx test or reload fails
Always test before reloading:
sudo nginx -t && sudo systemctl reload nginxTypical errors:
| Error text | Likely cause | Fix | Column |
|---|---|---|---|
| `cannot load certificate ... No such file or directory` | Wrong path, or the domain name in the path differs from the lineage name | Run `sudo certbot certificates` and copy the exact path | |
| `PEM_read_bio:bad end line` or `key values mismatch` | `ssl_certificate` and `ssl_certificate_key` come from different lineages | Point both at the same `/etc/letsencrypt/live/<name>/` directory | |
| `bind() to 0.0.0.0:443 failed (98: Address already in use)` | Another process or a duplicate `listen` holds port 443 | `sudo ss -tlnp \ | grep ':443'` |
| `Permission denied` on the key | nginx cannot read the file | Reload as root, which is the default for the master process |
Browser warns about an incomplete chain
If a browser accepts the site but curl or an API client reports unable to verify the first certificate, the server is sending only the leaf certificate. Use fullchain.pem, not cert.pem, for ssl_certificate. Verify what is served:
echo | openssl s_client -connect example.com:443 -servername example.com -showcerts 2>/dev/null | grep -E 's:|i:'You should see the leaf certificate and at least one intermediate.
The site still shows the old certificate
nginx loads certificates when it starts or reloads. After a renewal, the files on disk are new but the running process still holds the old ones. Reload nginx, and add a deploy hook so it happens on every renewal (see the chapter on hooks). Check what the live server returns:
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -enddate
sudo certbot certificatesIf the two expiry dates differ, the certificate on disk is newer and nginx needs a reload.
Renewal failures
Certbot renews a certificate only when it is within 30 days of expiry. Renewal reuses the settings saved in /etc/letsencrypt/renewal/<name>.conf, so a challenge that worked at issue time must still work later.
The timer is not running
Check the schedule and the last result:
systemctl list-timers | grep -i certbot
sudo systemctl status certbot.timer
sudo journalctl -u certbot.service --since "7 days ago"On Debian and Ubuntu the package installs a systemd timer or a cron entry in /etc/cron.d/certbot. If neither exists, for example after a snap or pip install, you must create a schedule yourself. Test the full path with:
sudo certbot renew --dry-runA dry run that succeeds proves the challenge, the saved renewal settings, and any hooks work together.
Renewal that worked once and now fails
These are the usual causes:
- The configuration changed. A new redirect, a removed
serverblock, or a firewall rule now blocks the challenge. - The authenticator changed. A renewal file that says
authenticator = nginxfails if the plugin package was removed. Reinstallpython3-certbot-nginx. - A manual DNS-01 certificate was requested with
--manual. Manual mode needs a person to create the TXT record, so unattended renewal fails. Use a DNS provider plugin or an authentication hook script instead. - A DNS provider API token expired or was revoked.
- A domain was removed from DNS or transferred. Remove the lineage with
sudo certbot delete --cert-name example.comif you no longer need it, or the failure repeats on every run.
Expiry warnings
Let's Encrypt no longer sends expiry emails by default, so set up your own check. A simple approach is to monitor the live certificate's end date from another host and alert when fewer than 20 days remain, which leaves time to fix a failed renewal after the 30-day window opens.
Quick reference
| Symptom | First command | Column |
|---|---|---|
| Timeout during HTTP-01 | `sudo ss -tlnp \ | grep ':80'` and check the firewall |
| Works over IPv4, fails validation | `dig +short AAAA example.com` | |
| 404 on challenge URL | `curl -i http://example.com/.well-known/acme-challenge/test` | |
| TXT record not found | `dig +short TXT _acme-challenge.example.com` | |
| Rate limit message | Read the retry time, then wait | |
| nginx will not reload | `sudo nginx -t` | |
| Old certificate still served | `sudo systemctl reload nginx` | |
| No automatic renewal | `systemctl list-timers \ | grep -i certbot` |
Exercise
A domain has a correct A record and ports 80 and 443 are open on IPv4. Certbot fails with Timeout during connect, yet curl -4 http://example.com/ works from outside. What is the most likely cause, and how do you confirm it?
Show answer
The domain probably has a stale or unreachable AAAA record. Let's Encrypt tries IPv6 first when an AAAA record exists. Confirm with dig +short AAAA example.com and curl -6 -I http://example.com/. If the IPv6 request fails, fix the IPv6 listener and firewall rule, or remove the AAAA record.
Exercise
sudo certbot certificates shows a certificate valid for 60 days, but a browser reports the site's certificate expires in 3 days. What happened, and what do you change so it does not recur?
Show answer
Certbot renewed the files on disk, but nginx still holds the old certificate in memory because it was never reloaded. Run sudo nginx -t && sudo systemctl reload nginx now. To prevent it, add an executable deploy hook in /etc/letsencrypt/renewal-hooks/deploy/ that runs systemctl reload nginx, then test with sudo certbot renew --dry-run.
Exercise
A wildcard certificate was issued with certbot certonly --manual --preferred-challenges dns. Issuance worked, but certbot renew fails 30 days before expiry. Why, and what are two ways to fix it?
Show answer
Manual mode requires a person to create the DNS TXT record each time, so the unattended renewal cannot complete it. Fix it by switching to a DNS provider plugin for your DNS host, which creates and removes the TXT record through its API, or by supplying authentication and cleanup hook scripts that do the same. Then re-issue the certificate so the renewal file records the new authenticator.