published fresh until

Certbot unauthorized behind Cloudflare: how do I fix it?

Summary As of October 2026, for an unauthorized HTTP challenge behind Cloudflare, verify the exact challenge response path, then choose a reachable webroot or automated TXT validation and test saved renewal settings (checked 2026-10-28).

Not for Cloudflare edge certificate selection; Caddy or Traefik automatic certificate configuration; general reverse-proxy selection

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

unauthorized — identify the affected certificate with certbot certificates before choosing a working challenge path. If the failed HTTP-01 challenge URL returns the wrong content, inspect challenge-path routing through Cloudflare and the origin. Run certbot certificates first, then inspect the failed hostname, authenticator and challenge URL in the Certbot log. The official challenge documentation establishes the required response and the Certbot issue records this proxy-routing failure; this deployment's cause and repair remain untested. Not for: Cloudflare edge certificates, Caddy automatic HTTPS or Traefik ACME configuration; this concerns Certbot validating an origin certificate.

How to repair validation

1. Identify the exact failure. unauthorized with Invalid response from and a challenge-path 404 points to a wrong HTTP response; a connection timeout calls for reachability checks instead. Do not treat every challenge failure as invalid API credentials. Record the selected authenticator and each hostname, including alternate names. Certbot issue and example response. 2. For HTTP-01, place a harmless probe file under the selected webroot's .well-known/acme-challenge/ directory and request it through the public hostname over HTTP and through any redirect to HTTPS. Confirm exact content rather than a login page, JavaScript challenge or app fallback. Ensure the proxy, redirects, access rules and both origin virtual hosts preserve the path. HTTP-01 starts on port 80 and accepts redirects only to HTTP/HTTPS on ports 80 or 443. Official challenge rules. 3. Choose the repair by constraint. If this path can be served reliably, use the webroot authenticator with the actual webroot. For an existing certificate on the documented Certbot 5.10.0 baseline (As of November 2026; checked 2026-11-15), use certbot reconfigure --cert-name example.com --webroot --webroot-path /var/www/letsencrypt, replacing the name and path. reconfigure tests the proposed renewal settings and saves them after success. Official renewal configuration guide. 4. If you cannot expose a reliable HTTP challenge path, or need a wildcard, use automated dns-01 TXT validation. Install the certbot-dns-cloudflare plugin using Certbot's platform instructions and confirm it appears in certbot plugins. Use a token restricted to only the required zones and the documented zone-edit permission; protect the credentials file with chmod 600. Never paste its contents into an agent conversation. Official plugin guide. 5. For a new certificate, the plugin's documented command is below, with only its credential-file path adapted. For an existing lineage, use certbot reconfigure --cert-name example.com --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini after the plugin and token are configured. Do not create unnecessary duplicate lineages just to change authenticators.

certbot certonly --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini -d example.com

6. Run certbot renew --dry-run to test the saved renewal flow. Ensure the web server reloads renewed files using an installer or an appropriate deploy hook; certonly alone does not configure that integration. Check the actual certificate served by the origin, since a CDN may present a different certificate to browsers. Certbot user guide.

Diagnostic: unauthorized

In Certbot #7275, _az describes the nginx authenticator putting a temporary challenge location only in the HTTP virtual host while a CDN connects to the origin over HTTPS. The HTTPS handler then does not serve the challenge. That is one documented cause, not proof that a proxied hostname cannot use HTTP-01.

Which repair fits?

ConstraintFirst choiceNot for
Reliable public HTTP challenge path and known document rootFix routing and use webrootWildcard issuance or a host whose HTTP path cannot be reached
No reliable public HTTP path, or wildcard requiredCloudflare plugin with automated TXT validationAssuming an API token repairs an HTTP routing error without changing authenticator
Only a browser-facing Cloudflare certificate is wrongInspect the edge certificate product separatelyReissuing the origin certificate as a universal fix

What to test

Test all certificate names, HTTP-to-HTTPS redirects, challenge-path bypasses, credential permissions, token scope and unattended renewal. Test from outside the origin network. Keep the chosen challenge available for future renewals; a temporary successful issuance does not establish automation. For TXT validation, confirm the authoritative record has propagated before increasing retries; the plugin exposes --dns-cloudflare-propagation-seconds when the default wait is insufficient.

Evidence and pitfalls

  • The nginx virtual-host failure is described by _az in the linked Certbot issue. It establishes a routing mechanism; it is not evidence that every current nginx installation has that bug.
  • In devdrake0's renewal report, the author reports a working webroot test after correcting the challenge directory. Community replies also distinguish validation from reloading the renewed certificate. This is historical corroboration of the routing fix, not a current release regression claim.
  • Do not switch Cloudflare to a weaker origin encryption mode merely to make the challenge pass. Fix validation or choose a different challenge.
  • Do not permanently disable the proxy or site security globally. Scope any necessary HTTP exception to the challenge path and test it.
  • Manual TXT edits without automated hooks create a recurring renewal chore. API token and global-key credential formats are different; follow the plugin's recommended token format.

A prompt for your agent

Your training data may predate the current Certbot renewal workflow. Read the linked Certbot reconfigure guide, Cloudflare plugin guide and Let's Encrypt challenge rules. Given the sanitized failure log and current authenticator, distinguish wrong HTTP content, reachability and TXT validation problems. Propose webroot or automated TXT validation, name the exact flags, test saved renewal and plan the certificate reload. Never request private keys or token values, weaken origin TLS, or assume the browser's certificate is the origin's certificate.

Limits

No certificate was issued, renewal executed or Cloudflare rule changed here. The community examples are historical; they do not establish a new Certbot regression. Token scope, redirect behaviour, authoritative records and certificate installation depend on the actual host and zone. Other ACME clients and Cloudflare certificate products require their own configuration guides.

Started from a post by @_az, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Certbot unauthorized behind Cloudflare: how do I fix it?
Summary: As of October 2026, for an unauthorized HTTP challenge behind Cloudflare, verify the exact challenge response path, then choose a reachable webroot or automated TXT validation and test saved renewal settings (checked 2026-10-28).
Copy for agent
get the whatworks thread certbot-unauthorized-behind-cloudflare-http-or-dns-challenge and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread certbot-unauthorized-behind-cloudflare-http-or-dns-challenge
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks