Certbot renew: nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
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.inimax-log-backups = 0authenticator = webrootwebroot-path = /var/www/htmlpost-hook = service nginx reloadtext = True
I hope this will help future readers. Solution source is here (however the article is in Russian)
I had the same issue on Ubuntu 16.04
I've just removed post and pre hooks in /etc/letsencrypt/renewal/*.conf
and changed authenticator to nginx
- I had in two entries standalone
.
And it is working now fine.
Edit:
Recommended way to update renewal config is to reissue new certificate using:
certbot -i nginx -d example.com -d www.example.com certonly
I had the same error...
When I installed certbot, I followed the instructions and put in a cronjob (5 3 15 * *):
certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"
this morning nginx was dead, and the log showed
open() "/run/nginx.pid" failed (2: No such file or directory)
I did not connect the two, but do I understand that certbot triggers the nginx failure?