"The site works normally, but the certificate expires in a few days and the automatic renewal keeps failing." Everything is green in the browser, so it can't be the server – that's the obvious assumption. But the HTTP-01 challenge from Let's Encrypt looks at the server from a different client than the customer's browser.
How the HTTP-01 challenge works
The ACME client on the server (for example certbot) places a file with a token under /.well-known/acme-challenge/. Let's Encrypt then fetches it via http://example.com/.well-known/acme-challenge/<token> – always over HTTP on port 80.
A redirect to HTTPS is allowed, and Let's Encrypt follows it. But the first request has to get in on port 80. Let's Encrypt also validates from several locations; all of them must reach the server.
Classic 1: port 80 is closed
Many admins close port 80 in the firewall because "everything runs over HTTPS anyway". Visitors who type https:// won't notice. Validation, however, fails with a timeout or "connection refused".
Check whether something listens on port 80 and whether the firewall allows it:
sudo ss -tlnp | grep ':80 '
sudo ufw status # if ufw is used
sudo nft list ruleset # with nftables
Don't forget firewalls at the hosting provider or in the cloud console, and geo-blocking rules. Blocking certain countries can also block Let's Encrypt validation locations.
Classic 2: an AAAA record pointing somewhere else
If a domain has an AAAA record, Let's Encrypt prefers to validate over IPv6. If that record points to an old or unrelated server, the request ends up there – and the token isn't found.
There is a fallback to IPv4 only if the IPv6 connection can't be established at all. If a different server answers on the IPv6 address, for example with a 404 page, validation fails.
Typical origin: a hosting migration where only the A record was updated (more in the article DNS migration without downtime). The customer's browser may be using IPv4 and sees nothing wrong.
A variant: the AAAA record is correct, but the web server doesn't listen on IPv6, for example because nginx is missing the line listen [::]:80;.
Check in this order
1. Query the DNS records and compare them with the server's actual IPs:
dig +short A example.com
dig +short AAAA example.com
ip -6 addr show scope global
2. Place a test file in the web root the ACME client uses:
echo ok | sudo tee /var/www/html/.well-known/acme-challenge/test
3. Fetch it from outside over both protocols – ideally from another machine, not from the server itself:
curl -4 -i http://example.com/.well-known/acme-challenge/test
curl -6 -i http://example.com/.well-known/acme-challenge/test
Both must return ok. If only -6 returns something else, the AAAA record or the IPv6 setup is the problem.
4. Do a dry run of the renewal and read the log:
sudo certbot renew --dry-run
sudo less /var/log/letsencrypt/letsencrypt.log
The dry run uses the staging environment and doesn't count against the rate limits.
Other causes and alternatives
A CAA record that only allows a different certificate authority also blocks issuance. And if port 80 has to stay closed for good reasons, the DNS-01 challenge via a TXT record is the right alternative – provided your DNS provider offers an API for it.
Checklist
- Do both
AandAAAArecords point to the right server? - Does the web server listen on port 80 over IPv4 and IPv6?
- Is port 80 open in the server firewall, the provider firewall and geo rules?
- Is the test file reachable from outside with
curl -4andcurl -6? - Does
certbot renew --dry-runsucceed? - Do the
CAArecords allow Let's Encrypt?
Check the AAAA record first, then the firewall. It saves a lot of guesswork – and a certificate that expires at the last minute.