Dev.to Security 🔐 Cybersecurity 👁 0 📖 1 min read

Let's Encrypt acme:error:unauthorized: fix

Let's Encrypt could not fetch the challenge file under /.well-known/acme-challenge/ from the right server and therefore refuses to issue the certificate. Common causes An AAAA record points to an IPv6 addres

Let's Encrypt could not fetch the challenge file under /.well-known/acme-challenge/ from the right server and therefore refuses to issue the certificate.

Common causes

  • An AAAA record points to an IPv6 address where no vhost or the wrong one answers – Let's Encrypt prefers IPv6.
  • DNS still points to the old server (migration, high TTL).
  • Rewrite or redirect rules (Nextcloud, WordPress, forced HTTPS to another host) catch the path.
  • Wrong --webroot path, so the file is not where nginx serves it.
  • A CDN, proxy or firewall blocks port 80.

How to check it

Check A and AAAA records

dig +short A example.com; dig +short AAAA example.com

Test the challenge path over IPv6

curl -6 -sI http://example.com/.well-known/acme-challenge/test

Is nginx listening on IPv6 port 80?

nginx -T 2>/dev/null | grep -E 'listen .*\[::\]:80'

What actually helps

  1. Add listen [::]:80; to the HTTP vhost, or delete a wrong AAAA record.
  2. Serve the challenge path before any redirect: location ^~ /.well-known/acme-challenge/ { root /var/www/letsencrypt; }.
  3. Lower the TTL before a migration and request the certificate only after the switch.

FAQ

Why does it work in my browser but not for Let's Encrypt?

Your browser may use IPv4 or a cache. Let's Encrypt queries over IPv6 as soon as an AAAA record exists, and validates from several locations.

How many failed attempts are allowed?

Let's Encrypt allows 5 failed validations per account, hostname and hour. Test with --dry-run against staging first.

Full page with every command and the German/Italian version: daniele-michelin.com/en/errors/letsencrypt-acme-error-unauthorized/

First published at daniele-michelin.com. The error lexicon covers HTTP, DNS, TLS, mail, database, PHP, nginx, systemd and Nextcloud, in German, English and Italian.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.