Attempting to renew cert produced an unexpected error: The nginx plugin is not working; there may be problems with your existing configuration. The error was: NoInstallationError(). Skipping

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. crt.sh | example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is: happyhourmenu.ca

I ran this command:

In sudo crontab -e:
0 4 * * 1 /usr/bin/certbot renew --quiet >> /var/log/le-renew.log

I received this email:

Attempting to renew cert (happyhourmenu.ca) from /etc/letsencrypt/renewal/happyhourmenu.ca.conf produced an unexpected error: The nginx plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError(). Skipping.
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/happyhourmenu.ca/fullchain.pem (failure)
1 renew failure(s), 0 parse failure(s)

My web server is (include version): Nginx 1.10.3

The operating system my web server runs on is (include version): Ubuntu 16.04.4

My hosting provider, if applicable, is: DigitalOcean/self-hosted

I can login to a root shell on my machine (yes or no, or I don't know): Yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): No

The strange thing is that everything worked fine when I first installed the certificate, and the cron job has been auto-renewing it weekly since late July with no issues. This is the first time there's been a problem!

Please issue this command and reply with any errors or with LE error log file:
/usr/bin/certbot renew

I ran that command and got the following error:

The following error was encountered:
[Errno 13] Permission denied: '/var/log/letsencrypt/.certbot.lock'
Either run as root, or set --config-dir, --work-dir, and --logs-dir to writeable paths.

I ran sudo /usr/bin/certbot renew got the following error:

Saving debug log to /var/log/letsencrypt/letsencrypt.log


Processing /etc/letsencrypt/renewal/happyhourmenu.ca.conf

Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator nginx, Installer nginx
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
tls-sni-01 challenge for happyhourmenu.ca
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Cleaning up challenges
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Encountered exception during recovery
nginx restart failed:
b''
b''
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 124, in _sol ve_challenges
resp = self.auth.perform(all_achalls)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 972, i n perform
self.restart()
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 787, i n restart
nginx_restart(self.conf('ctl'), self.nginx_conf)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1042, in nginx_restart
"nginx restart failed:\n%s\n%s" % (out.read(), err.read()))
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/certbot/error_handler.py", line 100, in _ca ll_registered
self.funcs-1
File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 303, in _cle anup_challenges
self.auth.cleanup(achalls)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 991, i n cleanup
self.restart()
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 787, i n restart
nginx_restart(self.conf('ctl'), self.nginx_conf)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1042, in nginx_restart
"nginx restart failed:\n%s\n%s" % (out.read(), err.read()))
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''
Attempting to renew cert (happyhourmenu.ca) from /etc/letsencrypt/renewal/happyhou rmenu.ca.conf produced an unexpected error: nginx restart failed:
b''
b''. Skipping.
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/happyhourmenu.ca/fullchain.pem (failure)


All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/happyhourmenu.ca/fullchain.pem (failure)

1 renew failure(s), 0 parse failure(s)

Making progress…

Try:
sudo /usr/bin/certbot renew --preferred-challenges http

Hi @jpgklassen

tls-sni-01 - validation is deprecated. Support ends 2019-02-13.

So use

sudo /usr/bin/certbot renew --nginx -preferred-challenges http

instead.

1 Like

Hi @JuergenAuer,

Thanks so much for your reply. I tried running that command and got the following error:

usage:
certbot [SUBCOMMAND] [options] [-d DOMAIN] [-d DOMAIN] ...

Certbot can obtain and install HTTPS/TLS/SSL certificates. By default,
it will attempt to use a webserver both for obtaining and installing the
certificate.
certbot: error: unrecognized arguments: -preferred-challenges http

I think there was a typo in the command you provided; --preferred-challenges should have two dashes, correct? I tried sudo /usr/bin/certbot renew --nginx --preferred-challenges http and got this error:

Saving debug log to /var/log/letsencrypt/letsencrypt.log


Processing /etc/letsencrypt/renewal/happyhourmenu.ca.conf

Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator nginx, Installer nginx
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for happyhourmenu.ca
Using default addresses 80 and [::]:80 ipv6only=on for authentication.
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Cleaning up challenges
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Encountered exception during recovery
nginx restart failed:
b''
b''
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 124, in _solve_challenges
resp = self.auth.perform(all_achalls)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 972, in perform
self.restart()
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 787, in restart
nginx_restart(self.conf('ctl'), self.nginx_conf)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1042, in nginx_restart
"nginx restart failed:\n%s\n%s" % (out.read(), err.read()))
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/certbot/error_handler.py", line 100, in _call_registered
self.funcs-1
File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 303, in _cleanup_challenges
self.auth.cleanup(achalls)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 991, in cleanup
self.restart()
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 787, in restart
nginx_restart(self.conf('ctl'), self.nginx_conf)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1042, in nginx_restart
"nginx restart failed:\n%s\n%s" % (out.read(), err.read()))
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''
Attempting to renew cert (happyhourmenu.ca) from /etc/letsencrypt/renewal/happyhourmenu.ca.conf produced an unexpected error: nginx restart failed:
b''
b''. Skipping.
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/happyhourmenu.ca/fullchain.pem (failure)


All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/happyhourmenu.ca/fullchain.pem (failure)

1 renew failure(s), 0 parse failure(s)

Please try (without nginx):
sudo /usr/bin/certbot renew --preferred-challenges http
Also show
/etc/letsencrypt/renewal/happyhourmenu.ca.conf

I would like to ask what happens when you try to restart nginx outside of Certbot, like with service nginx start. Do you get a more useful error? Is there something in the nginx error log?

Yep, two dashes are required :wink:

Hi @rg305,

I tried this and got this error:

Saving debug log to /var/log/letsencrypt/letsencrypt.log


Processing /etc/letsencrypt/renewal/happyhourmenu.ca.conf

Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator nginx, Installer nginx
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for happyhourmenu.ca
Using default addresses 80 and [::]:80 ipv6only=on for authentication.
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Cleaning up challenges
nginx: [error] invalid PID number "" in "/run/nginx.pid"
Encountered exception during recovery
nginx restart failed:
b''
b''
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 124, in _solve_challenges
resp = self.auth.perform(all_achalls)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 972, in perform
self.restart()
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 787, in restart
nginx_restart(self.conf('ctl'), self.nginx_conf)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1042, in nginx_restart
"nginx restart failed:\n%s\n%s" % (out.read(), err.read()))
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/certbot/error_handler.py", line 100, in _call_registered
self.funcs-1
File "/usr/lib/python3/dist-packages/certbot/auth_handler.py", line 303, in _cleanup_challenges
self.auth.cleanup(achalls)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 991, in cleanup
self.restart()
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 787, in restart
nginx_restart(self.conf('ctl'), self.nginx_conf)
File "/usr/lib/python3/dist-packages/certbot_nginx/configurator.py", line 1042, in nginx_restart
"nginx restart failed:\n%s\n%s" % (out.read(), err.read()))
certbot.errors.MisconfigurationError: nginx restart failed:
b''
b''
Attempting to renew cert (happyhourmenu.ca) from /etc/letsencrypt/renewal/happyhourmenu.ca.conf produced an unexpected error: nginx restart failed:
b''
b''. Skipping.
All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/happyhourmenu.ca/fullchain.pem (failure)


All renewal attempts failed. The following certs could not be renewed:
/etc/letsencrypt/live/happyhourmenu.ca/fullchain.pem (failure)

1 renew failure(s), 0 parse failure(s)

Also show
/etc/letsencrypt/renewal/happyhourmenu.ca.conf

Here are the contents of my /etc/letsencrypt/renewal/happyhourmenu.ca.conf, as requested:

renew_before_expiry = 30 days

version = 0.22.2
archive_dir = /etc/letsencrypt/archive/happyhourmenu.ca
cert = /etc/letsencrypt/live/happyhourmenu.ca/cert.pem
privkey = /etc/letsencrypt/live/happyhourmenu.ca/privkey.pem
chain = /etc/letsencrypt/live/happyhourmenu.ca/chain.pem
fullchain = /etc/letsencrypt/live/happyhourmenu.ca/fullchain.pem

Options used in the renewal process

[renewalparams]
account = 3997bf60bb09f8192570d01501046af9
installer = nginx
authenticator = nginx

Do you have pre- or post-hooks?

Check

/etc/letsencrypt/renewal-hooks/pre
/etc/letsencrypt/renewal-hooks/post

perhaps delete files there (first: Make a backup).

When I run sudo service nginx start, I get this error:

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

My nginx error log contains:

2018/12/11 11:51:11 [notice] 31231#31231: signal process started
2018/12/11 11:51:11 [error] 31231#31231: invalid PID number "" in "/run/nginx.pid"
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:11 [emerg] 31232#31232: still could not bind()
2018/12/11 11:51:14 [notice] 31233#31233: signal process started
2018/12/11 11:51:14 [error] 31233#31233: invalid PID number "" in "/run/nginx.pid"
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 11:51:14 [emerg] 31234#31234: still could not bind()
2018/12/11 12:09:09 [notice] 31304#31304: signal process started
2018/12/11 12:09:09 [error] 31304#31304: invalid PID number "" in "/run/nginx.pid"
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:09 [emerg] 31305#31305: still could not bind()
2018/12/11 12:09:12 [notice] 31306#31306: signal process started
2018/12/11 12:09:12 [error] 31306#31306: invalid PID number "" in "/run/nginx.pid"
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:09:12 [emerg] 31307#31307: still could not bind()
2018/12/11 12:20:56 [notice] 31418#31418: signal process started
2018/12/11 12:20:56 [error] 31418#31418: invalid PID number "" in "/run/nginx.pid"
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:56 [emerg] 31419#31419: still could not bind()
2018/12/11 12:20:59 [notice] 31420#31420: signal process started
2018/12/11 12:20:59 [error] 31420#31420: invalid PID number "" in "/run/nginx.pid"
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 12:20:59 [emerg] 31421#31421: still could not bind()
2018/12/11 13:46:21 [notice] 31699#31699: signal process started
2018/12/11 13:46:21 [error] 31699#31699: invalid PID number "" in "/run/nginx.pid"
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:21 [emerg] 31700#31700: still could not bind()
2018/12/11 13:46:24 [notice] 31701#31701: signal process started
2018/12/11 13:46:24 [error] 31701#31701: invalid PID number "" in "/run/nginx.pid"
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:46:24 [emerg] 31702#31702: still could not bind()
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:443 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to 0.0.0.0:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: bind() to [::]:80 failed (98: Address already in use)
2018/12/11 13:57:39 [emerg] 31796#31796: still could not bind()

Thanks @JuergenAuer, I checked these folders but they are both empty.

Let's find out what is using those addresses and if these two pid path results match:
Please show:
netstat -pant | grep -i listen | grep -E ':80|:443'
grep -Ri 'nginx.pid' /etc/nginx/
grep -Ri 'nginx.pid' /usr/lib/systemd/

1 Like

Here is the output:

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10192/nginx: worker
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 10192/nginx: worker
tcp6 0 0 :::80 :::* LISTEN 10192/nginx: worker
tcp6 0 0 :::443 :::* LISTEN 10192/nginx: worker

Here is the output:

/etc/nginx/nginx.conf:pid /run/nginx.pid;

This command had no output.

So, nginx is already running on those ports when...
Which explains why you can't start it (again):

Let's refocus on this (and ignore chasing the wild geese):

Try and show outcome of:
sudo service nginx restart
[[ It should show something like: ]]
[[ "Redirecting to /bin/systemctl restart nginx.service" ]]
If this restart fails, lets hit it with a bigger hammer - LOL...
Then try:

  1. netstat -pant | grep -i listen | grep -E ‘:80|:443’
  2. kill -USR1 `cat /run/nginx.pid`
  3. netstat -pant | grep -i listen | grep -E ‘:80|:443’

[pay no attention to the word "kill" - it will restart automatically]
[notice the numbers in the output (after LISTEN) - they should have changed from before to after the "kill"]

This may be another stray goose, but also try to find which pid number is being used:
find / -name nginx.service

Sorry for disappearing! Life got busy for a few days.

I ran sudo service nginx restart and got the following output:

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

I ran netstat -pant | grep -i listen | grep -E ':80|:443' and got the following output:

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10192/nginx: worker
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 10192/nginx: worker
tcp6 0 0 :::80 :::* LISTEN 10192/nginx: worker
tcp6 0 0 :::443 :::* LISTEN 10192/nginx: worker

I tried running this command and got the following output:

cat: /run/nginx.pid: No such file or directory
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

I ran sudo find / -name nginx.service and got the following output:

/etc/systemd/system/multi-user.target.wants/nginx.service
/lib/systemd/system/nginx.service
/var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/nginx.service

Please show output of:

OK, then we need to find where its' PID is at...
find / -name nginx.pid

Please show file:

This command had no output!

Here are the contents of that file:

[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/ng$
TimeoutStopSec=5
KillMode=mixed

[Install]
WantedBy=multi-user.target

nginx is running:

We can't stop it.
We can't restart it.
We can't kill it.

No more Mr. Nice Guy.

Please show netstat outputs (before and after):
netstat -pant | grep -i listen | grep -E ':80|:443'
systemctl stop nginx.service
systemctl start nginx.service
netstat -pant | grep -i listen | grep -E ':80|:443'

The PID should have changed.