Skip to content
  1. LuzineDebug
  2. DevOps, servers & cloud
  3. Certbot failed to authenticate some domains (aut…
DevOps, servers & cloud Intermediate ≈ 15 min to fix

Fix "Certbot failed to authenticate some domains" (Let’s Encrypt, Timeout during connect, acme-challenge 404)

Error message
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.
In short

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.

Be the first to confirm this fix

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

  1. Port 80 closed: ufw/firewalld, AWS security group, OVH/Hetzner firewall, or a missing port forward on a home router.
  2. DNS pointing elsewhere: A record not propagated yet, or an old AAAA (IPv6) record to another server; Let’s Encrypt tries IPv6 first.
  3. Wrong server block or webroot: the request hits the default_server, another site, or --webroot -w does not match the served root.
  4. Rule intercepting /.well-known/: rewrite to index.php, a location ~ /\. that blocks hidden files, or HTTP authentication.
  5. Proxy or CDN in front (orange-cloud Cloudflare) with redirect or security rules that get in the way of validation.

Step-by-step fix

  1. 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.

    bash
    dig +short example.com A
    dig +short example.com AAAA
    curl -4 -s https://ifconfig.me; echo
  2. 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).

    bash
    # 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
  3. 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 200 and the content ok.

    bash
    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
  4. Serve /.well-known/acme-challenge/ before any redirect

    In the port 80 server block, add a dedicated location before the HTTPS redirect or the rewrite to the application.

    nginx
    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;
        }
    }
  5. Run Certbot again, dry run first

    --dry-run uses the Let’s Encrypt staging environment and does not count against issuance rate limits. Once it passes, run the real command.

    bash
    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
  6. 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.

    bash
    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

All DevOps, servers & cloud errors →