Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Most Let’s Encrypt errors on Apache are not certificate-cryptography problems. They are validation or deployment problems: the hostname resolves to the wrong server, port 80 cannot be reached, Apache selects the wrong virtual host, a rewrite hides the challenge file, or Apache is using the wrong certificate file. Fix the failing stage first, then test renewal separately.

This guide covers HTTP-01 and DNS-01 validation, Apache virtual-host and listener checks, certificate-file selection, safe reloads, and renewal failures.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Identify which stage is failing

Certbot performs two different jobs. An authenticator proves that you control a hostname by answering an ACME challenge. An installer changes Apache configuration to use the resulting certificate. A failure during validation has a different remedy from a failure while Apache is being edited or reloaded.

Validation errors

Messages such as “connection refused,” “timeout,” “404,” “unauthorized,” or “invalid response” mean that Let’s Encrypt could not retrieve the expected challenge response. Troubleshoot DNS, routing, the challenge method, Apache’s port listeners, virtual hosts, rewrites, and file permissions.

Installation or reload errors

Errors from Apache syntax checks, missing files, unreadable private keys, duplicate directives, or a failed service reload occur after validation. The certificate may already have been issued; correct the Apache configuration and reload it safely.

Renewal errors

A certificate that worked previously can still fail at renewal. DNS may have changed, a firewall or load balancer may have been introduced, the webroot may have moved, or a manual authentication step may no longer run. Treat renewal as a separate operational test rather than assuming a working HTTPS site proves renewal will succeed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start with a five-minute triage

  1. Write down every hostname in the certificate request, including www names and any other aliases.
  2. Check each hostname’s public A and AAAA records. Confirm that they point to the endpoint where the intended Apache instance runs.
  3. Determine whether Certbot is using HTTP-01 or DNS-01. HTTP-01 needs public HTTP access; DNS-01 needs an authoritative TXT record.
  4. For HTTP-01, test a file in the exact /.well-known/acme-challenge/ path from a network outside the server.
  5. After correcting the cause, run one validation attempt. Do not repeatedly request certificates while the same error remains; repeated failures can trigger CA rate limits.

Use the error text as a routing clue. A 404 normally means the request reached a web server but not the expected token. A timeout or refusal usually means that the request never reached a usable port-80 listener.

Check DNS before changing Apache

Let’s Encrypt validates every requested hostname independently. A single stale alias can make the whole order fail even when the main site works.

Verify both address families

Query the public DNS view for both record types:

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

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

Replace the names with every hostname in the Certbot request. If an AAAA record leads to an old machine, an IPv6-capable validator can reach that machine instead of the IPv4 server. Remove the stale record or configure the IPv6 endpoint to serve the same challenge.

Confirm the actual public endpoint

Check that the returned address belongs to the server, reverse proxy, load balancer, or NAT device that is supposed to handle Apache traffic. If several front ends exist, each one must preserve the challenge path or route it to the same webroot. Internal DNS answers are not sufficient; validation comes from the public Internet and may use multiple vantage points.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix HTTP-01 challenge failures

With HTTP-01, Let’s Encrypt requests a URL in this form:

http://example.com/.well-known/acme-challenge/TOKEN

Certbot places the token in a webroot or serves it through an Apache authenticator. A working HTTPS home page does not prove that this HTTP challenge URL is reachable or returns the token.

Test the exact path and webroot

  1. Find the webroot configured for the failing virtual host. If Certbot uses --webroot -w /var/www/example, the token must be under /var/www/example/.well-known/acme-challenge/.
  2. Create a harmless test file in that directory:
sudo mkdir -p /var/www/example/.well-known/acme-challenge
printf 'acme-testn' | sudo tee /var/www/example/.well-known/acme-challenge/health.txt
  1. Request it externally, not only with a local browser:
curl -i http://example.com/.well-known/acme-challenge/health.txt

The response should be HTTP 200 with the exact text acme-test. Test each hostname, including its www alias. Delete the test file when finished.

Correct virtual-host selection

Inspect the port-80 virtual hosts and confirm that the intended one has the right ServerName and ServerAlias. The request must not land on a default site, an old deployment, or a redirect-only host whose document root differs from the Certbot webroot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apachectl -S

On systems where the binary is named differently, the equivalent Apache control command is commonly apache2ctl -S. Compare the output with the hostname and address returned by DNS. If a proxy or load balancer fronts Apache, verify that it forwards /.well-known/acme-challenge/ without changing the host header or path.

Make sure Apache listens on port 80

HTTP-01 normally requires public TCP port 80. Check the configuration for Listen 80 and verify a process is actually bound:

sudo ss -ltnp | grep ':80'

Also inspect cloud firewalls, host firewalls, NAT rules, security groups, and provider-level filters. A local listener cannot help if the public address forwards port 80 elsewhere. A timeout commonly indicates filtering or a broken route; “connection refused” commonly indicates that no reachable service is listening or that a firewall is actively rejecting the connection.

Remove rewrites and access rules that intercept the challenge

Global HTTP-to-HTTPS redirects are normally acceptable when they preserve the challenge path, but custom rewrite rules can send the request to an application, return a 404, require authentication, or loop between hosts. Exclude /.well-known/acme-challenge/ from application routing and authentication. Check .htaccess, RewriteRule directives, and front-end proxy rules as well as the vhost file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Directory permissions must allow Apache to traverse each parent directory and read the token file. The web server does not need write access to the entire site; grant only the controlled access required by the chosen Certbot method. If a security module or container policy blocks reads, the Apache error log will usually show the denial.

Read the logs while testing

Watch the Apache error log and access log during a single request. Confirm which vhost handled the request, the status code returned, and the filesystem path Apache attempted to read. This distinguishes a wrong webroot from a network failure before you run Certbot again.

Use DNS-01 when HTTP cannot work

DNS-01 proves control by publishing a TXT record at _acme-challenge.example.com. It avoids inbound HTTP and is the documented route for wildcard certificates such as *.example.com.

What must be true

  • You must control the authoritative DNS zone for the name.
  • The TXT value generated for the active authorization must be published exactly, without quotation marks added to the value itself.
  • Authoritative nameservers must have the new record before validation starts; recursive resolvers can retain old answers during propagation.
  • If several authorizations are active, multiple TXT values may temporarily be valid. Do not delete an older value until you have confirmed which authorization is being checked.

Automate carefully

A Certbot DNS plugin can create and remove TXT records through a provider’s API. Give the API credential the narrowest zone permissions possible and keep it outside web-accessible directories. Manual DNS authentication does not become automatic merely because the first certificate was issued; a renewal job needs a repeatable authentication hook or an equivalent automated plugin.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Query the authoritative DNS servers, not just one local resolver, when diagnosing propagation:

dig TXT _acme-challenge.example.com

A missing, mistyped, stale, or not-yet-published TXT record produces a DNS-01 failure even when Apache and HTTPS are completely healthy.

Choose the right challenge method

Consideration HTTP-01 DNS-01
Required control Public HTTP reachability on port 80, correct vhost routing, and a readable challenge path Authoritative DNS control and TXT publication under _acme-challenge
Wildcard certificates Not the documented route for wildcard issuance Supports wildcard certificates
Good fit Ordinary hostnames on a server that can expose port 80 Wildcards, firewalled or private origins, and architectures where HTTP cannot reach Apache
Typical failures Wrong DNS, firewall or NAT, missing listener, wrong vhost, rewrite, 404, timeout, or refusal Missing, incorrect, stale, or unpropagated TXT records

Switching methods is a design decision, not a way to hide an unresolved configuration error. If port 80 is intentionally unavailable, DNS-01 is usually the practical choice; if DNS automation is not reliable, fixing HTTP-01 may be safer for ordinary hostnames.

Configure Apache to use the correct certificate files

Certbot maintains the current certificate set as symlinks under /etc/letsencrypt/live/<domain>/. Point Apache at those live paths rather than copying a dated file from an archive directory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Apache 2.4.8 and newer

Use the full certificate chain and the matching private key:

SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

fullchain.pem contains the leaf certificate followed by the necessary intermediate chain. privkey.pem is secret; restrict ownership and mode so the Apache process can read it while ordinary users cannot. Never publish it through the document root, source repository, backup download, or support ticket.

Older Apache releases

Older Apache versions may require the leaf certificate and chain separately, using cert.pem with chain.pem. Check the installed Apache version and its SSL module documentation before changing directives. Do not substitute cert.pem for fullchain.pem on a modern installation when clients need the intermediate chain.

Match names and permissions

Ensure the certificate covers every requested hostname and that the SSL virtual host has the intended ServerName and ServerAlias. A correct file path still fails if Apache cannot traverse the /etc/letsencrypt/live symlink chain or read the target files. Fix group ownership or ACLs deliberately rather than making the private key world-readable.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Validate configuration and reload safely

  1. Run Apache’s configuration test before touching the running service:
sudo apachectl configtest

Proceed only when it reports Syntax OK. If it names a file or line, fix that exact issue first. Common causes include a typo in a certificate path, a missing SSL module, duplicate directives, and permissions on the private key.

  1. Inspect the Apache error log for certificate parsing, permission, protocol, or virtual-host messages.
  2. Reload gracefully so existing connections can finish:
sudo systemctl reload apache2

Some distributions use the service name httpd instead:

sudo systemctl reload httpd
  1. Confirm the service remains active and request the site over HTTPS. Check the served certificate’s names and expiry from an external client, not only from the local certificate file.

Certbot’s Apache installer needs administrator privileges to edit configuration and reload the daemon. If you run Certbot without sufficient privileges, separate issuance from installation: obtain the certificate with an authenticator, then make controlled Apache changes as an administrator.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Fix renewal failures before the certificate expires

Run a simulated renewal regularly:

sudo certbot renew --dry-run

The dry run exercises the configured authenticator and, where applicable, deployment and reload hooks without replacing the production certificate. A successful HTTPS page is not a renewal test.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Inspect the renewal configuration

Review the relevant files in /etc/letsencrypt/renewal/. Confirm the recorded authenticator, webroot, domains, DNS plugin, and any hooks still match the current server. Logs in /var/log/letsencrypt/ show the exact authorization and hook failure.

Check scheduled execution and hooks

Verify that the system’s timer or cron job runs as the expected user and has network, DNS-API, and filesystem access. A deploy or post-renewal hook should reload Apache only after a successful renewal. Test the hook command separately and make sure it exits with a success status; a broken hook can leave a newly issued certificate unused.

Manual authentication needs automation

Certificates created with Certbot’s manual plugin do not renew automatically unless authentication hooks are supplied. If renewal requires a person to create a TXT record or token each time, replace that process with a supported automated DNS plugin or a reliable hook before relying on unattended renewal.

Error-to-cause troubleshooting table

Observed error Most likely checks
Connection refused Port 80 listener, host or provider firewall, NAT forwarding, proxy target, and whether DNS points to the active server
Timeout Public routing, firewall drops, security groups, IPv6 path, and load-balancer health
HTTP-01 404 Selected vhost, ServerName/ServerAlias, webroot, rewrite or application routing, token-file permissions, and proxy path handling
HTTP-01 wrong content Another server or vhost is answering, a cache is serving old content, or a proxy is changing the request
DNS-01 unauthorized TXT name or value, authoritative zone, propagation, stale conflicting records, and DNS-plugin credentials
Apache will not reload apachectl configtest, certificate paths, SSL module, private-key readability, duplicate directives, and log messages
Renewal works in theory but not unattended Timer or cron execution, expired API credentials, changed webroot, manual authentication, and deploy/reload hook status

A repeatable recovery sequence

  1. List every hostname and classify the failing stage.
  2. Verify public A and AAAA answers and the endpoint each address reaches.
  3. Choose HTTP-01 only when port 80 and the challenge path can be publicly served; otherwise configure DNS-01.
  4. Test a file at the exact HTTP-01 path, or query the authoritative DNS TXT record for DNS-01.
  5. Correct vhost routing, rewrites, firewall rules, NAT, permissions, or DNS automation indicated by that test.
  6. Run one Certbot attempt and save its output.
  7. Point Apache at the current live files, normally fullchain.pem and privkey.pem, then run apachectl configtest.
  8. Reload gracefully and verify the externally served certificate.
  9. Run certbot renew --dry-run and confirm the scheduled job and hooks before the next expiry window.

Let’s Encrypt considers validation successful only when its checks receive the expected responses from the web server. That is why a visible HTTPS page, a locally readable token, or a certificate file on disk is not enough by itself: the public challenge request must reach the correct service and return the exact response.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.