A Renewed Certificate Nginx Still Won't Serve

Certbot says success. The browser says otherwise. Here's the gap.

Contents

certbot renew reports success. certbot certificates shows a fresh expiry date, months out. And a browser hitting the site still shows the old certificate, still counting down toward the expiry you just supposedly fixed. This is one of the more disorienting TLS problems, because every tool you check individually reports that everything worked, and the actual symptom — the wrong certificate being served — seems to have no obvious owner.

This is worth internalising early because the fix, once you see it, is genuinely trivial — the confusing part is entirely in locating which of several plausible layers actually owns the failure. The cause, in the overwhelming majority of cases, is that Certbot wrote a new certificate file to disk and never told nginx about it. Nginx reads its certificate files once, at startup or reload, and holds them in memory for the life of the worker processes; a file on disk changing underneath a running nginx process does nothing until nginx is told to reload. Certbot renewing the file is necessary but not sufficient — the missing step is the one that gets nginx to actually pick the new file up.

Why the Reload Step Goes Missing

Certbot supports a --deploy-hook (or the equivalent renew_hook in its renewal config) specifically to run a command after a successful renewal, and reloading nginx is meant to be exactly that command. It’s very easy to install Certbot, run it interactively once, get the initial certificate issued, and never revisit the automated renewal path to check whether a deploy hook is actually configured — the first issuance often reloads nginx as a side effect of the interactive setup, which papers over the fact that the automated renewal never wires that reload up at all.

An open steel padlock with its shackle raised, photographed against a white background.
An unlocked padlock: a renewed certificate on disk does nothing until the server reloads and presents it. Photo: Padlock unlocked (4141457002) by Lee Haywood from Wollaton, Nottingham, England, CC BY-SA 2.0, via Wikimedia Commons.
1
2
# check what Certbot will actually run on renewal
sudo cat /etc/letsencrypt/renewal/example.com.conf

Look specifically for a renew_hook line. If it’s missing, or empty, the automated certbot renew — run nightly by a systemd timer or cron job on most installs — is silently renewing the certificate file on disk and never reloading the service that’s supposed to serve it. This can go unnoticed for months, because the renewal itself reports success every single night, right up until the old certificate actually expires and the browser warning shows up.

The Fix: An Explicit Deploy Hook

The direct fix is adding a deploy hook that reloads nginx, either globally for all certificates or per-certificate if you manage several with different services:

1
sudo certbot renew --deploy-hook "systemctl reload nginx"

Running it once manually like this confirms the hook works, but for it to apply on every future automated renewal, it needs to be persisted either in the renewal config file itself or as a standing hook script:

1
2
# persists across all future renewals for this cert
sudo certbot renew --cert-name example.com --deploy-hook "systemctl reload nginx"

Certbot writes the --deploy-hook value into the certificate’s renewal config on first use with that flag, so running it once with the flag is enough — future automated renewals will read the saved hook and run it without the flag needing to be repeated. Alternatively, a script dropped into /etc/letsencrypt/renewal-hooks/deploy/ runs automatically after every renewal for every certificate, which is the better option if you manage multiple certificates and want one hook to cover all of them:

1
2
3
# /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
#!/bin/sh
systemctl reload nginx
1
sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh

Using reload rather than restart matters here: a reload re-reads configuration and certificate files while keeping existing connections alive, whereas a restart briefly drops the listening socket, which is unnecessary disruption for what should be a seamless certificate swap.

This distinction matters more than it might seem for anything with long-lived connections — a websocket-based dashboard, a streaming media session — where a restart’s brief socket drop is directly visible to whoever’s connected at that moment, while a reload’s in-place certificate swap is not. For a homelab running one or two low-traffic services this is a minor point; for anything serving multiple people or long sessions, defaulting to reload everywhere and reserving restart for changes reload genuinely can’t apply (a changed listen port, for instance) is worth making a habit rather than a special case.

Confirming the Actual Certificate Being Served

Before assuming the fix worked, verify what’s actually being served, since a browser cache can show you a stale certificate even after nginx has correctly reloaded — browsers cache TLS session state and certificate chains more aggressively than most people expect. openssl s_client bypasses any browser-side caching entirely:

1
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates
1
2
notBefore=Aug 25 00:00:00 2026 GMT
notAfter=Nov 23 23:59:59 2026 GMT

Compare notAfter against what certbot certificates reports as the renewed certificate’s expiry. If they match, nginx is serving the current certificate and any remaining “wrong certificate” symptom in a browser is purely client-side caching — closing and reopening the browser, or testing in a private window, confirms this quickly.

It’s worth checking this from a machine outside your own network too, ideally one that’s never visited the site before, since a home network’s own DNS cache or a router-level DNS cache can independently mask a change that’s genuinely already live everywhere else. A quick check from a public online SSL checker tool, or simply curl from a cloud VM if you have one handy, rules out any local caching layer between you and the server as the source of a stubborn “still looks wrong” result.

A Second Common Cause: SNI and Multiple Certificates on One IP

If the site in question shares an IP address with other domains — common on a homelab reverse proxy fronting several services — a mismatched or missing server_name directive can mean nginx is correctly reloaded with the correct certificate for one domain, while still serving a different, stale certificate for another. TLS’s Server Name Indication (SNI) is how nginx picks which certificate to present for a given connection, based on the hostname the client asked for during the handshake, and a server block with an ambiguous or duplicate server_name can leave nginx falling back to whichever certificate happens to be configured on the default server block rather than the one you just renewed.

1
sudo nginx -T 2>/dev/null | grep -B2 "ssl_certificate " | grep -A2 server_name

Testing with openssl s_client and an explicit -servername flag, as shown earlier, is the reliable way to confirm which certificate is actually presented for a specific hostname, since a plain browser test against an IP with multiple domains configured can pick up whichever server block nginx treats as the default rather than the one you intended to test.

Why Certbot’s Own Timer Can Mislead You

Checking systemctl status certbot.timer and seeing it active and recently run is easy to mistake for confirmation that the deploy hook ran too — the timer firing only confirms that certbot renew was invoked, not that any given certificate’s hook executed, since Certbot skips certificates that aren’t yet within their renewal window (by default, the last 30 days before expiry) without any error. A certificate that renewed successfully three months ago, with a hook that was only added after that renewal, won’t have that hook actually exercised until the next genuine renewal falls due — meaning a hook you just added can look completely untested for weeks, and the only way to confirm it actually works is a manual --dry-run.

1
sudo certbot renew --dry-run --deploy-hook "systemctl reload nginx"

The --dry-run flag exercises the full renewal and hook logic against Let’s Encrypt’s staging environment without touching your production certificate, which is the safe way to confirm a newly added hook actually fires before trusting it to run unattended months from now.

Troubleshooting: When the Reload Itself Isn’t Enough

If a manual systemctl reload nginx after renewal still doesn’t fix it, a few other causes are worth checking, roughly in order of likelihood:

Multiple nginx configs reference the certificate with different paths. If you’ve got more than one server block, or a config split across multiple included files, check that all of them point at the same certificate path rather than one pointing at a directory copy that Certbot doesn’t actually update. Certbot updates the files under /etc/letsencrypt/live/example.com/, which are themselves symlinks to the actual versioned certificate files — if a config was written pointing at an /etc/letsencrypt/archive/ path directly rather than the live symlink, it’ll keep serving whatever version was current when that path was written, permanently, regardless of how many times you renew.

1
sudo nginx -T 2>/dev/null | grep -i ssl_certificate

A wildcard certificate renewed via a DNS-01 challenge fails silently and nobody notices for weeks. DNS-01 challenges (required for wildcard certificates) depend on a DNS provider API credential that can expire or be revoked independently of anything nginx-related; the renewal fails at the issuance stage, before nginx is even involved, and the only symptom is the same stale certificate you’d see from a missing deploy hook. Checking certbot renew --dry-run output for actual errors, not just exit status, catches this category before it reaches the reload step at all.

Nginx is running inside a container with the certificate bind-mounted, and the mount is stale. If nginx itself runs in Docker and the certificate directory is mounted from the host, confirm the container is actually seeing the renewed files — docker exec into the container and check the certificate’s modification time directly, since a misconfigured or cached bind mount can leave a container seeing an older snapshot of the directory than the host actually has on disk.

The reload succeeded but a load balancer or CDN in front of nginx is caching the old handshake. If there’s a reverse proxy, load balancer, or CDN edge terminating TLS before traffic even reaches your nginx instance, verifying directly against nginx’s own IP (bypassing DNS and any front-end layer) isolates whether the problem has already moved beyond nginx entirely.

nginx -t fails silently as part of the reload, and the old process just keeps running. A reload that encounters a config syntax error doesn’t restart nginx with broken config — the old worker processes, with the old certificate, simply keep running unaffected while the reload itself fails. Always check the reload’s exit status and journalctl -u nginx after any reload triggered by a hook, rather than assuming success because the renewal step reported it.

1
sudo nginx -t && sudo systemctl reload nginx

Chaining the test before the reload, as above, means a config error blocks the reload explicitly with an error message, rather than the reload command exiting successfully while nginx quietly keeps its old configuration and old certificate loaded.

Is a Deploy Hook Worth Setting Up Now, Before It Bites

Yes, immediately, and it’s a five-minute fix regardless of which certificate management approach you’re running. The failure mode here is uniquely bad because it’s invisible until the exact moment the old certificate actually expires — everything reports success for months right up until a hard failure with no warning in between. If you’re running your own certificate authority rather than Let’s Encrypt for internal services, as covered in running your own certificate authority with step-ca, the same principle holds even more strongly, since there’s no public monitoring or transparency log nudging you toward noticing a stale reload the way Certificate Transparency logs sometimes do for public certificates. Either way, confirm the deploy hook exists and actually runs before you need it, rather than after a renewal quietly stopped mattering to anything actually serving traffic — the same category of “it reported success but nothing downstream noticed” as a cron job that silently stopped running without anything watching for its absence.

Smarc
Written by Smarc

Founder and editor of Aside House. A lifelong tinkerer who self-hosts far more than is sensible, hardens Linux boxes for fun, and prods the latest AI tools to see what they can really do. The how-to guides here are the notes Smarc wishes had existed the first time round.

Smarc is the editor of Aside House. The homelab, the hardware and the opinions are real; the guides are drafted with AI assistance. Infrastructure details are genericised on purpose.