Fix Let's Encrypt certificate errors
Let's Encrypt errors come from a failed domain check, usually DNS pointing elsewhere, port 80 blocked or a broken renewal timer, so check each before you retry.
- Updated Nov 27, 2026
- Markdown
Find why a Let's Encrypt certificate was not issued or renewed, fix the DNS, port or timer, and confirm it with a dry run.
- A domain you control and a server with certbot
- SSH access with sudo
Certbot prints Challenge failed for domain app.example.com, the browser shows an expired certificate warning, or the log says you hit a rate limit. In every case the authority could not confirm that you control the domain at that moment, or your server stopped renewing. Work through DNS, port 80, the proxy in front, CAA records and the renewal timer, in that order.
How it works#
Let’s Encrypt issues a certificate only after your server proves control of the domain through the ACME protocol. With the common HTTP-01 challenge, the authority gives certbot a token, certbot serves it at http://app.example.com/.well-known/acme-challenge/<token>, and the authority fetches that URL from the internet over port 80. If anything between the authority and certbot breaks, the check fails. Certificates last 90 days, so renewals must also work unattended. The challenge types are described in the Let’s Encrypt docs.
Step 1: Read the exact error#
sudo certbot certificates
sudo tail -n 60 /var/log/letsencrypt/letsencrypt.logThe first lists each certificate and its expiry. The second holds the detailed failure. Typical messages are Timeout during connect (likely firewall problem), Connection refused, NXDOMAIN looking up A for ..., and Invalid response ... 404. Each points at a different step below.
Step 2: Check that DNS points at this server#
dig +short app.example.com A
dig +short app.example.com AAAA
curl -s https://ifconfig.meThe A record must match the public IP of the server running certbot, for example 203.0.113.10. A stale AAAA record is a frequent trap: Let’s Encrypt prefers IPv6 when it exists, so a wrong AAAA record fails the check even when the A record is right. Remove or fix it. If the name does not resolve at all, see fix a domain that does not resolve. For DNS basics, see check DNS with dig.
Step 3: Check that port 80 reaches the right process#
From another machine:
curl -v http://app.example.com/.well-known/acme-challenge/testYou expect an HTTP answer, even a 404. A timeout points at a firewall: open port 80 in ufw and in your provider’s firewall. A refusal means nothing listens on port 80. If a web server already uses it, certbot’s --standalone mode cannot bind it, so use the webroot or nginx plugin instead, or stop the server briefly. Also check that your HTTP-to-HTTPS redirect does not send /.well-known/acme-challenge/ to a page that fails. Redirecting to HTTPS on the same host is accepted, but a redirect loop is not. See redirect HTTP to HTTPS explained.
Step 4: Check CAA records#
dig +short CAA example.comNo output means no restriction. If records exist, one must allow letsencrypt.org, for example 0 issue "letsencrypt.org". CAA is inherited from the parent domain, so a record on example.com applies to app.example.com unless the subdomain has its own. Fix it at your DNS provider.
Step 5: Look at rate limits#
If the error mentions a rate limit, wait. Let’s Encrypt limits certificates per registered domain, duplicate certificates and failed validations over time windows. The exact numbers are published on the rate limits page and can change, so read it there instead of trusting a number from memory. To avoid burning limits while you debug, use the staging environment:
sudo certbot certonly --staging -d app.example.comStaging certificates are not trusted by browsers. Once staging succeeds, run the real command once.
Step 6: Fix expired certificates and the renewal timer#
If the certificate already expired, renewal did not run. On most systems certbot installs a systemd timer:
systemctl list-timers | grep certbot
sudo systemctl status certbot.timerIf the timer is missing or inactive, enable it with sudo systemctl enable --now certbot.timer. Some installs use a cron entry in /etc/cron.d/certbot instead. Then run the real renewal:
sudo certbot renewRenewal reuses the settings saved in /etc/letsencrypt/renewal/app.example.com.conf. If you issued with --standalone and later started a server on port 80, renewal now fails for the same port clash. Switch the authenticator in that file or reissue with the nginx plugin. A web server must be reloaded to use a new file, so a deploy hook such as --deploy-hook "systemctl reload nginx" matters. See renew Let’s Encrypt certificates.
Check it worked#
sudo certbot renew --dry-run
echo | openssl s_client -connect app.example.com:443 -servername app.example.com 2>/dev/null | openssl x509 -noout -datesThe dry run should end with Congratulations, all simulated renewals succeeded. The notAfter date should be about 90 days ahead.
Prevent it#
- Run
certbot renew --dry-runafter every change to the web server, firewall or DNS. - Monitor the certificate expiry date from outside, so you hear about it before visitors do.
- Keep the AAAA record correct or absent.
Edge cases and gotchas#
- Cloudflare or another proxy in front: The authority reaches the proxy, not your server. Pause the proxy or use the DNS challenge.
- Wildcards: They need the DNS-01 challenge, not HTTP-01.
- New domain too fresh: Records need time to reach the authority’s resolvers. Check with
dig @1.1.1.1. - Several servers behind one name: The check may hit a server without the token. Make challenge answers reach the same host.
- Docker proxies: If a container publishes port 80, certbot on the host cannot bind it. Stop it briefly or use webroot.
- Clock drift: A server clock far off makes TLS checks fail oddly. Keep time sync on.
Troubleshooting#
| Symptom | Likely cause | Fix |
|---|---|---|
| Timeout during connect | Port 80 blocked | Open port 80 in ufw and the provider firewall |
| NXDOMAIN looking up A | Record missing or wrong name | Add the A record, wait for DNS |
| Invalid response, 404 or wrong content | Another server or app answers on port 80 | Route the challenge path to certbot’s webroot |
| Fails only for IPv6 | Wrong AAAA record | Fix or remove the AAAA record |
| CAA record prevents issuance | CAA lists another authority | Add 0 issue "letsencrypt.org" |
| Too many failed validations or certificates | Rate limit | Wait, use --staging while debugging |
| Certificate expired, renew never ran | Timer disabled | Enable certbot.timer, run certbot renew |
Quick reference#
sudo certbot certificates
sudo tail -n 60 /var/log/letsencrypt/letsencrypt.log
dig +short app.example.com A
dig +short CAA example.com
sudo certbot renew --dry-run
systemctl list-timers | grep certbotRelated lessons#
- HTTPS and Let’s Encrypt: how issuance works end to end.
- Renew Let’s Encrypt certificates: timers, hooks and testing renewals.
- Check DNS with dig: verify the records the check depends on.
- Redirect HTTP to HTTPS explained: keep the challenge path reachable.
Next#
Continue with Fix a domain that does not resolve.
Check what you learned
Frequently asked questions
Why did Let's Encrypt fail to issue my certificate?
The authority could not prove you control the domain. The usual reasons are that the domain points at a different server, port 80 is blocked, a proxy answers instead of certbot, or a CAA record forbids the issuer.
Why is my Let's Encrypt certificate expired?
Automatic renewal did not run or failed. Check the certbot timer with systemctl list-timers and test with certbot renew --dry-run.
What is the Let's Encrypt rate limit?
Let's Encrypt limits how many certificates and failed validations a domain can have in a time window. The exact numbers are on their rate limits page and can change, so test with the staging environment to avoid hitting them.
How do I test certificate renewal without issuing a real one?
Run sudo certbot renew --dry-run. It uses the staging environment, so it checks the whole renewal path without counting against production limits.
Sources
Keep going: guides and tutorials
- Docker Container Restarting in a Loop: 5 Causes, Fixed Five real reasons a Docker container keeps restarting, each reproduced with its exit code, the command that finds it and the fix. Then the same crash on Levelrail.
- Our Health Check Failed and the Deploy Went Live Anyway A postmortem from our own dogfood run: a failed readiness probe still received traffic. What broke, why two correct parts added up to a bug, and the fix.
- Roll Back a Failed Docker Deploy Without Downtime Ship a broken release on purpose, watch your users stay on the old version, then roll back with one command. Real commands, real output, self-hosted.