# Fix Let's Encrypt certificate errors

> Let's Encrypt errors come from a failed domain check, usually DNS pointing elsewhere, port 80 blocked or a broken renewal timer, so check each before you retry.

URL: https://levelrail.com/learn/troubleshooting/fix-lets-encrypt-certificate-errors/
Updated: 2026-11-27

Certbot prints `Challenge failed for domain app.example.com`, the browser shows an expired certificate warning, or the log says you hit a rate limit. In every case the authority could not confirm that you control the domain at that moment, or your server stopped renewing. Work through DNS, port 80, the proxy in front, CAA records and the renewal timer, in that order.

## How it works

[Let's Encrypt](https://levelrail.com/learn/glossary/#lets-encrypt)) issues a certificate only after your server proves control of the domain through the [ACME](https://levelrail.com/learn/glossary/#acme)) protocol. With the common HTTP-01 challenge, the authority gives certbot a token, certbot serves it at `http://app.example.com/.well-known/acme-challenge/<token>`, and the authority fetches that URL from the internet over port 80. If anything between the authority and certbot breaks, the check fails. Certificates last 90 days, so renewals must also work unattended. The challenge types are described in the [Let's Encrypt docs](https://letsencrypt.org/docs/challenge-types/).

## Step 1: Read the exact error

```bash
sudo certbot certificates
sudo tail -n 60 /var/log/letsencrypt/letsencrypt.log
```

The first lists each certificate and its expiry. The second holds the detailed failure. Typical messages are `Timeout during connect (likely firewall problem)`, `Connection refused`, `NXDOMAIN looking up A for ...`, and `Invalid response ... 404`. Each points at a different step below.

## Step 2: Check that DNS points at this server

```bash
dig +short app.example.com A
dig +short app.example.com AAAA
curl -s https://ifconfig.me
```

The A record must match the public IP of the server running certbot, for example 203.0.113.10. A stale AAAA record is a frequent trap: Let's Encrypt prefers IPv6 when it exists, so a wrong AAAA record fails the check even when the A record is right. Remove or fix it. If the name does not resolve at all, see [fix a domain that does not resolve](https://levelrail.com/learn/troubleshooting/fix-a-domain-that-does-not-resolve/)). For DNS basics, see [check DNS with dig](https://levelrail.com/learn/domains-https/check-dns-with-dig/)).

## Step 3: Check that port 80 reaches the right process

From another machine:

```bash
curl -v http://app.example.com/.well-known/acme-challenge/test
```

You expect an HTTP answer, even a 404. A timeout points at a firewall: open port 80 in `ufw` and in your provider's firewall. A refusal means nothing listens on port 80. If a web server already uses it, certbot's `--standalone` mode cannot bind it, so use the webroot or nginx plugin instead, or stop the server briefly. Also check that your HTTP-to-HTTPS redirect does not send `/.well-known/acme-challenge/` to a page that fails. Redirecting to HTTPS on the same host is accepted, but a redirect loop is not. See [redirect HTTP to HTTPS explained](https://levelrail.com/learn/domains-https/redirect-http-to-https-explained/)).

## Step 4: Check CAA records

```bash
dig +short CAA example.com
```

No output means no restriction. If records exist, one must allow `letsencrypt.org`, for example `0 issue "letsencrypt.org"`. CAA is inherited from the parent domain, so a record on `example.com` applies to `app.example.com` unless the subdomain has its own. Fix it at your DNS provider.

## Step 5: Look at rate limits

If the error mentions a rate limit, wait. Let's Encrypt limits certificates per registered domain, duplicate certificates and failed validations over time windows. The exact numbers are published on the [rate limits page](https://letsencrypt.org/docs/rate-limits/) and can change, so read it there instead of trusting a number from memory. To avoid burning limits while you debug, use the staging environment:

```bash
sudo certbot certonly --staging -d app.example.com
```

Staging certificates are not trusted by browsers. Once staging succeeds, run the real command once.

## Step 6: Fix expired certificates and the renewal timer

If the certificate already expired, renewal did not run. On most systems certbot installs a systemd timer:

```bash
systemctl list-timers | grep certbot
sudo systemctl status certbot.timer
```

If the timer is missing or inactive, enable it with `sudo systemctl enable --now certbot.timer`. Some installs use a cron entry in `/etc/cron.d/certbot` instead. Then run the real renewal:

```bash
sudo certbot renew
```

Renewal reuses the settings saved in `/etc/letsencrypt/renewal/app.example.com.conf`. If you issued with `--standalone` and later started a server on port 80, renewal now fails for the same port clash. Switch the authenticator in that file or reissue with the nginx plugin. A web server must be reloaded to use a new file, so a deploy hook such as `--deploy-hook "systemctl reload nginx"` matters. See [renew Let's Encrypt certificates](https://levelrail.com/learn/domains-https/renew-lets-encrypt-certificates/)).

## Check it worked

```bash
sudo certbot renew --dry-run
echo | openssl s_client -connect app.example.com:443 -servername app.example.com 2>/dev/null | openssl x509 -noout -dates
```

The dry run should end with `Congratulations, all simulated renewals succeeded`. The `notAfter` date should be about 90 days ahead.

## Prevent it

- Run `certbot renew --dry-run` after every change to the web server, firewall or DNS.
- Monitor the certificate expiry date from outside, so you hear about it before visitors do.
- Keep the AAAA record correct or absent.

## Edge cases and gotchas

- **Cloudflare or another proxy in front:** The authority reaches the proxy, not your server. Pause the proxy or use the DNS challenge.
- **Wildcards:** They need the DNS-01 challenge, not HTTP-01.
- **New domain too fresh:** Records need time to reach the authority's resolvers. Check with `dig @1.1.1.1`.
- **Several servers behind one name:** The check may hit a server without the token. Make challenge answers reach the same host.
- **Docker proxies:** If a container publishes port 80, certbot on the host cannot bind it. Stop it briefly or use webroot.
- **Clock drift:** A server clock far off makes TLS checks fail oddly. Keep time sync on.

## Troubleshooting

| Symptom | Likely cause | Fix |
| --- | --- | --- |
| Timeout during connect | Port 80 blocked | Open port 80 in ufw and the provider firewall |
| NXDOMAIN looking up A | Record missing or wrong name | Add the A record, wait for DNS |
| Invalid response, 404 or wrong content | Another server or app answers on port 80 | Route the challenge path to certbot's webroot |
| Fails only for IPv6 | Wrong AAAA record | Fix or remove the AAAA record |
| CAA record prevents issuance | CAA lists another authority | Add `0 issue "letsencrypt.org"` |
| Too many failed validations or certificates | Rate limit | Wait, use `--staging` while debugging |
| Certificate expired, renew never ran | Timer disabled | Enable certbot.timer, run `certbot renew` |

## Quick reference

```bash
sudo certbot certificates
sudo tail -n 60 /var/log/letsencrypt/letsencrypt.log
dig +short app.example.com A
dig +short CAA example.com
sudo certbot renew --dry-run
systemctl list-timers | grep certbot
```

## Related lessons

- [HTTPS and Let's Encrypt](https://levelrail.com/learn/domains-https/https-and-lets-encrypt/)): how issuance works end to end.
- [Renew Let's Encrypt certificates](https://levelrail.com/learn/domains-https/renew-lets-encrypt-certificates/)): timers, hooks and testing renewals.
- [Check DNS with dig](https://levelrail.com/learn/domains-https/check-dns-with-dig/)): verify the records the check depends on.
- [Redirect HTTP to HTTPS explained](https://levelrail.com/learn/domains-https/redirect-http-to-https-explained/)): keep the challenge path reachable.

## Next

Continue with [Fix a domain that does not resolve](https://levelrail.com/learn/troubleshooting/fix-a-domain-that-does-not-resolve/)).

## Frequently asked questions

### Why did Let's Encrypt fail to issue my certificate?

The authority could not prove you control the domain. The usual reasons are that the domain points at a different server, port 80 is blocked, a proxy answers instead of certbot, or a CAA record forbids the issuer.

### Why is my Let's Encrypt certificate expired?

Automatic renewal did not run or failed. Check the certbot timer with systemctl list-timers and test with certbot renew --dry-run.

### What is the Let's Encrypt rate limit?

Let's Encrypt limits how many certificates and failed validations a domain can have in a time window. The exact numbers are on their rate limits page and can change, so test with the staging environment to avoid hitting them.

### How do I test certificate renewal without issuing a real one?

Run sudo certbot renew --dry-run. It uses the staging environment, so it checks the whole renewal path without counting against production limits.


## Sources

- [Let's Encrypt, challenge types](https://letsencrypt.org/docs/challenge-types/)
- [Let's Encrypt, rate limits](https://letsencrypt.org/docs/rate-limits/)
