Automate SSL Renewal with Certbot and Hooks
sudo certbot renew --dry-run to test, and add a deploy hook so your web server reloads the new certificate.How Certbot renewal works
Let's Encrypt certificates last 90 days today, and the default drops to 64 days from 10 February 2027 and 45 days from 16 February 2028 (Let's Encrypt announcement). Certbot's renew command looks at every certificate it manages and renews the ones that are due. As of Certbot 4.0.0 a certificate is due when less than a third of its lifetime remains, and before 4.0.0 the threshold was a fixed 30 days (Certbot docs). Check yours with certbot --version. Running it daily or twice a day is safe, because it does nothing when no certificate is due.
Check that renewal is scheduled
Packages from most distributions and snap installs create a systemd timer. Check it:
systemctl list-timers | grep certbot
cat /etc/cron.d/certbot 2>/dev/null
If you see neither, add a cron entry:
0 3,15 * * * root certbot renew --quiet --deploy-hook "systemctl reload nginx"
Test with a dry run
sudo certbot renew --dry-run
The dry run uses the staging server and does not change your live certificate. A pass means the challenge method, ports and permissions all work. Run it after any server change.
Reload the server after renewal
A renewed file on disk does nothing until the service reloads it. Use a deploy hook, which runs only after a successful renewal:
sudo mkdir -p /etc/letsencrypt/renewal-hooks/deploy
sudo tee /etc/letsencrypt/renewal-hooks/deploy/reload-web.sh > /dev/null <<'EOF'
#!/bin/sh
systemctl reload nginx
EOF
sudo chmod +x /etc/letsencrypt/renewal-hooks/deploy/reload-web.sh
Replace nginx with apache2 or httpd as needed.
Why renewal fails
| Symptom | Cause | Fix |
|---|---|---|
| Timeout or connection refused | Port 80 blocked | Open port 80 in the firewall |
| 404 on the challenge file | Redirect or location rule intercepts /.well-known/acme-challenge/ | Allow that path over HTTP |
| Domain no longer points to the server | DNS changed | Fix DNS or remove the certificate |
| Rate limit | Too many attempts | Wait and use dry runs while testing |
| DNS challenge fails | API token expired | Renew the token in the plugin config |
More detail in how to fix Let's Encrypt renewal failures.
Watch the expiry anyway
Automation can fail silently. Check the live certificate regularly with the SSL Checker or the Bulk SSL Checker. The wider industry schedule is in the 47-day roadmap. If you only need a one-off certificate, you can issue one on TryFreeSSL.com.
FAQ
How often should the timer run?
Twice a day is the usual recommendation. The extra runs are harmless.
Do I need to restart Nginx?
A reload is enough and does not drop connections.
Can I renew a single certificate?
Yes: sudo certbot renew --cert-name example.com.
What if I use wildcard certificates?
They need a DNS challenge, so make sure the DNS plugin and its credentials stay valid.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.