Re: nginx failed to restart
Posted: Tue Jul 26, 2016 1:09 pm
You can try to look who uses port like this:
Code: Select all
netstat -tulpn | grep :80
Code: Select all
netstat -tulpn | grep :80
Code: Select all
/usr/local/letsencrypt/certbot-auto --standalone renew --pre-hook "service nginx stop" --post-hook "service nginx start"
Code: Select all
root@one:~# systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2019-09-05 07:21:11 CEST; 2h 5min ago
Docs: http://nginx.org/en/docs/
Process: 29384 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 19280 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)
Main PID: 24679 (code=exited, status=0/SUCCESS)
Here is how I solve it temporarily:
Sep 05 07:21:09 nginx[19280]: nginx: [emerg] bind() to xx.xx.xx.xx:80 failed (98: Address already in use)
Sep 05 07:21:10 nginx[19280]: nginx: [emerg] bind() to xx.xx.xx.xx:443 failed (98: Address already in use)
Sep 05 07:21:10 nginx[19280]: nginx: [emerg] bind() to xx.xx.xx.xx:80 failed (98: Address already in use)
Sep 05 07:21:10 nginx[19280]: nginx: [emerg] bind() to xx.xx.xx.xx:443 failed (98: Address already in use)
Sep 05 07:21:10 nginx[19280]: nginx: [emerg] bind() to xx.xx.xx.xx:80 failed (98: Address already in use)
Sep 05 07:21:11 nginx[19280]: nginx: [emerg] still could not bind()
Sep 05 07:21:11 systemd[1]: nginx.service: Control process exited, code=exited status=1
Sep 05 07:21:11 systemd[1]: Failed to start nginx - high performance web server.
Sep 05 07:21:11 systemd[1]: nginx.service: Unit entered failed state.
Sep 05 07:21:11 systemd[1]: nginx.service: Failed with result 'exit-code'.
root@one:~# netstat -tulpn | grep --color :80
tcp 0 0 xx.xx.xx.xx:80 0.0.0.0:* LISTEN 29611/nginx: master
tcp 0 0 xx.xx.xx.xx:8080 0.0.0.0:* LISTEN 2689/apache2
tcp 0 0 127.0.0.1:8081 0.0.0.0:* LISTEN 2689/apache2
tcp 0 0 0.0.0.0:8083 0.0.0.0:* LISTEN 1070/nginx: master
root@one:~# fuser -k 80/tcp
80/tcp: 29611 29612 29613
root@one:~# kill -9 29611
-bash: kill: (29611) - No such process
root@one:~# kill -9 1070
root@one:~# service nginx start