Let's Encrypt certificates last 90 days by design. That short lifetime is a good thing—it forces automation—but it also means a broken renewal job will quietly take down HTTPS three months after you finish setting up a server. Understanding how domain validation works saves a lot of guesswork when something fails to renew.
HTTP-01 vs. DNS-01 challenges
To issue a certificate, the ACME server needs proof that you control the domain. Two challenge types cover almost every case:
- HTTP-01 asks your server to serve a specific token at
http://yourdomain/.well-known/acme-challenge/<token>over port 80. It is the simplest option and requires no DNS API keys, but port 80 must be open to the public internet and it cannot issue wildcard certificates (*.example.com). - DNS-01 asks you to create a temporary
TXTrecord at_acme-challenge.yourdomain. It works for wildcard certificates and internal services that do not expose port 80, at the cost of storing a scoped DNS API token on the server.
For most single-server web apps, HTTP-01 is the right default. Only reach for DNS-01 when you genuinely need a wildcard certificate or when the host sits on a private network without public port 80. Also check that both your IPv4 A and IPv6 AAAA DNS records point to the same server before requesting a cert—Let's Encrypt prefers IPv6 when an AAAA record exists.
Using Certbot with Nginx
If Nginx is already your edge web server on Ubuntu, the cleanest setup is Certbot with the Nginx plugin:
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
Certbot edits your Nginx site config to add the certificate paths and HTTP-to-HTTPS redirect, then installs a systemd timer that runs twice daily to check for certificates within 30 days of expiry.
If you prefer not to let Certbot rewrite your Nginx files—for instance, when your Nginx configs are managed in Git—use certonly --webroot instead:
sudo certbot certonly --webroot -w /var/www/acme -d example.com
And add a small location block in Nginx so challenges bypass any reverse proxy or authentication rule:
location /.well-known/acme-challenge/ {
root /var/www/acme;
}
When using certonly, add a deploy hook so Nginx reloads automatically whenever a certificate renews—otherwise Nginx keeps serving the old certificate from memory until the next manual reload:
sudo certbot renew --dry-run --deploy-hook "systemctl reload nginx"
Using Caddy for zero-config HTTPS
For new projects where you do not specifically need Nginx, Caddy handles ACME registration, HTTP-01 and TLS-ALPN-01 challenges, OCSP stapling, and automatic renewal out of the box with no separate Certbot process:
example.com {
reverse_proxy 127.0.0.1:8080
}
That three-line Caddyfile obtains and renews the certificate, redirects HTTP to HTTPS, and proxies traffic. Check Caddy's logs via journalctl -u caddy if a domain fails validation right after a DNS change. One common snag with Caddy is forgetting that it stores certificates under /var/lib/caddy/.local/share/caddy—make sure that directory is writable and backed up if you migrate hosts.
Testing renewal and inspecting live certs
Always run a dry-run renewal right after initial setup. It uses Let's Encrypt's staging environment so you do not burn production rate limits:
sudo certbot renew --dry-run
sudo systemctl list-timers | grep certbot
sudo journalctl -u certbot.service -n 30
To check the live certificate chain and expiry date on any server from your terminal, use openssl s_client:
echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null \
| openssl x509 -noout -dates -subject -issuer
Watch out for two common renewal blockers: forgetting to keep port 80 open in UFW when using HTTP-01, and hitting production rate limits (5 duplicate certificates per week) while debugging a broken config. Whenever you are testing, use --staging or --dry-run first, and set up an external uptime monitor that alerts you 14 days before any certificate expires.