Certbot and nginx versions:
certbot installed using certbot.eff.org install guide.
Getting ssl certificates works fine:
certbot --nginx
But, in renewal of cerbot certificated
certbot renew --dry-run
nginx fails to start causing:
nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
I have tried changing post-hook and pre-hook in /etc/letsencrypt/renewal/*com.conf/
installer=nginx
Adding post and pre hooks in /etc/letsencrypt/renewal-hooks/pre/
and /etc/lestencrypt/renewal-hooks/post/
to stop and start nginx service.
Seems nginx is not starting properly or isn't stop properly. after renewal completes nginx fails with (code=exited, status=1/FAILURE)
Nginx error log show:
Error while certbot renew:
Try to execute:
sudo service nginx restart
Then test your nginx configuration file(s) (until you see "nginx: configuration file /etc/nginx/nginx.conf test is successful")
sudo nginx -s reload -t
Pay attention on paths to certificates, and other stuff
and then reload configuration without -t
option:
sudo nginx -s reload
It's not recommended to modify configuration files in /etc/letsencrypt/
but creating (if it doesn't exist) and modifying cli.ini file here is working for me. You can specify post-hook
in this file once and it will work for all your certificates, see my current file:
# /etc/letsencrypt/cli.ini
max-log-backups = 0
authenticator = webroot
webroot-path = /var/www/html
post-hook = service nginx reload
text = True
I hope this will help future readers. Solution source is here (however the article is in Russian)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With