Fix "Certbot failed to authenticate some domains" (Let’s Encrypt, Timeout during connect, acme-challenge 404)
Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems: Domain: example.com Type: connection Detail: 203.0.113.10: Timeout during connect (likely firewall problem)
- Detail: 203.0.113.10: Invalid response from http://example.com/.well-known/acme-challenge/Xk3pQ9vLr2: 404
- Type: unauthorized
- Detail: DNS problem: NXDOMAIN looking up A for example.com - check that a DNS record exists for this domain
- Hint: The Certificate Authority failed to verify the temporary nginx configuration changes made by Certbot. Ensure the listed domains point to this nginx server and that it is accessible from the internet.
- Some challenges have failed.
Let’s Encrypt could not verify that you control the domain: it did not reach your server on port 80 (Timeout during connect), or it found something other than the validation file there (Invalid response … 404). Check that DNS points to this server (A and AAAA), that port 80 is open from the internet, then run sudo certbot --nginx -d example.com again.
What this error means
With the HTTP-01 challenge (used by --nginx, --apache and --webroot), Certbot drops a token in /.well-known/acme-challenge/ and Let’s Encrypt fetches it over HTTP, on port 80 only, from several places on the internet. Type: connection + Timeout during connect: no answer, port 80 is filtered (firewall, cloud security group, home router) or the IP is wrong. Type: unauthorized + Invalid response … 404: a server did answer, but not with the token, because the request lands on another server or another server block, or a redirect or rule diverts it. DNS problem: NXDOMAIN: the domain does not exist in DNS yet.
Common causes
- Port 80 closed:
ufw/firewalld, AWS security group, OVH/Hetzner firewall, or a missing port forward on a home router. - DNS pointing elsewhere: A record not propagated yet, or an old AAAA (IPv6) record to another server; Let’s Encrypt tries IPv6 first.
- Wrong server block or webroot: the request hits the
default_server, another site, or--webroot -wdoes not match the servedroot. - Rule intercepting
/.well-known/: rewrite toindex.php, alocation ~ /\.that blocks hidden files, or HTTP authentication. - Proxy or CDN in front (orange-cloud Cloudflare) with redirect or security rules that get in the way of validation.
Step-by-step fix
-
Check DNS (A and AAAA)
Both must point to this server, or the AAAA must be removed if the server has no IPv6 configured. Compare with the machine’s public IP.
dig +short example.com A dig +short example.com AAAA curl -4 -s https://ifconfig.me; echo -
Open port 80
Let’s Encrypt only validates on port 80 for HTTP-01. Open it in the system firewall and in the provider’s one (security group, panel firewall).
# Ubuntu / Debian (ufw) sudo ufw allow 'Nginx Full' sudo ufw status # RHEL / Fedora (firewalld) sudo firewall-cmd --permanent --add-service=http --add-service=https sudo firewall-cmd --reload -
Test from outside
Drop a test file where Certbot writes its tokens, then fetch it from another machine or your phone on mobile data. You should get
200and the contentok.sudo mkdir -p /var/www/html/.well-known/acme-challenge echo ok | sudo tee /var/www/html/.well-known/acme-challenge/test curl -i http://example.com/.well-known/acme-challenge/test -
Serve /.well-known/acme-challenge/ before any redirect
In the port 80
serverblock, add a dedicatedlocationbefore the HTTPS redirect or the rewrite to the application.server { listen 80; listen [::]:80; server_name example.com www.example.com; location ^~ /.well-known/acme-challenge/ { root /var/www/html; default_type text/plain; } location / { return 301 https://$host$request_uri; } } -
Run Certbot again, dry run first
--dry-runuses the Let’s Encrypt staging environment and does not count against issuance rate limits. Once it passes, run the real command.sudo nginx -t && sudo systemctl reload nginx sudo certbot certonly --nginx -d example.com -d www.example.com --dry-run sudo certbot --nginx -d example.com -d www.example.com -
Cannot open port 80? Switch to the DNS challenge
The DNS-01 challenge needs no open port: Certbot creates a TXT record through your DNS provider’s API. It is also the only way to get a wildcard certificate. Keep the credentials file at
chmod 600.sudo apt install python3-certbot-dns-cloudflare sudo chmod 600 /root/.secrets/cloudflare.ini sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /root/.secrets/cloudflare.ini -d example.com -d "*.example.com"
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Keep port 80 open permanently with a redirect to HTTPS: automatic renewals need it.
- Test renewal after every configuration change with
sudo certbot renew --dry-run. - When migrating servers, update the AAAA record together with the A record, or delete it.
Frequently asked questions
Can I validate on a port other than 80?
Not with HTTP-01: Let’s Encrypt always connects to port 80. If your provider or ISP blocks it, use the DNS-01 challenge.
"Too many failed authorizations recently", what now?
You hit the failed-validation limit for that domain (5 per hour per account). Wait an hour and test with --dry-run until the configuration validates.
Does it work with Cloudflare in proxy mode (orange cloud)?
Often yes, but an "Always Use HTTPS" rule, a redirect or bot protection can block validation. Temporarily switch the record to "DNS only", or use the Cloudflare DNS plugin.
Useful tools for this error
More DevOps, servers & cloud errors
- Fix "upstream timed out (110: Connection timed out)" and 504 Gateway Time-out in Nginx
- Fix "nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)"
- Fix "413 Request Entity Too Large" (Nginx, PHP, Express, Cloudflare)
- Fix "Resource not accessible by integration" in GitHub Actions
- Fix the 404 on refresh of a SPA on Vercel ("404: NOT_FOUND"), Netlify and Nginx
- Fix "An error occurred (AccessDenied) when calling the PutObject operation" on AWS S3
- Fix "The connection to the server localhost:8080 was refused" with kubectl