Josh
Josh

Reputation: 3070

Certbot MisconfigurationError: nginx restart failed

On a setup with Ubuntu 16.04, Certbot 0.28.0, and nginx 1.10.3, I can't use Certbot to renew an existing certificate.

  1. When I run sudo certbot renew, it fails and I get these errors:

    Hook command "nginx -s stop" returned error code 1
    Error output from nginx:
    nginx: [error] invalid PID number "" in "/run/nginx.pid"
    
  2. And when I run sudo certbot --nginx, it fails with this error:

    certbot.errors.MisconfigurationError: nginx restart failed:
    

Upvotes: 14

Views: 8519

Answers (1)

James Ikubi
James Ikubi

Reputation: 2948

The error you shared above was not complete, the actual error looks something like:

Encountered exception during recovery: certbot.errors.MisconfigurationError: nginx restart failed:
nginx: [emerg] bind() to [::]:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)

To fix this error, run:

sudo fuser -k 443/tcp
sudo fuser -k 80/tcp
sudo service nginx restart
sudo certbot --nginx

Read more on this here: https://stevespindler.com/whats-taking-up-my-time/

Upvotes: 14

Related Questions