Unable to restart or reload Nginx

February 19, 2018 3.2k views
Nginx Ubuntu 16.04

Running sudo service nginx restart command gives below error:

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

Running systemctl status nginx.service gives below:

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2018-02-19 14:48:17 UTC; 3min 11s ago
  Process: 9834 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 9830 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 10807 (code=exited, status=0/SUCCESS)

Feb 19 14:48:16 ubuntu-milanchheda-laravel-blog nginx[9834]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Feb 19 14:48:16 ubuntu-milanchheda-laravel-blog nginx[9834]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Feb 19 14:48:16 ubuntu-milanchheda-laravel-blog nginx[9834]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Feb 19 14:48:16 ubuntu-milanchheda-laravel-blog nginx[9834]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Feb 19 14:48:16 ubuntu-milanchheda-laravel-blog nginx[9834]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Feb 19 14:48:17 ubuntu-milanchheda-laravel-blog nginx[9834]: nginx: [emerg] still could not bind()
Feb 19 14:48:17 ubuntu-milanchheda-laravel-blog systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 19 14:48:17 ubuntu-milanchheda-laravel-blog systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Feb 19 14:48:17 ubuntu-milanchheda-laravel-blog systemd[1]: nginx.service: Unit entered failed state.
Feb 19 14:48:17 ubuntu-milanchheda-laravel-blog systemd[1]: nginx.service: Failed with result 'exit-code'.

On doing lsof -i :80 below is the response:

COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   10867     root   12u  IPv4 116061      0t0  TCP *:http (LISTEN)
nginx   10867     root   13u  IPv6 116062      0t0  TCP *:http (LISTEN)
nginx   10868 www-data   12u  IPv4 116061      0t0  TCP *:http (LISTEN)
nginx   10868 www-data   13u  IPv6 116062      0t0  TCP *:http (LISTEN)
1 Answer
milanchheda February 19, 2018
Accepted Answer

Alright. I got it fixed by running the below commands:

sudo fuser -k 443/tcp
service nginx restart
  • Worked for me fixing bigbluebutton install - a dozen other solutions did not. Thanks for posting.

Have another answer? Share your knowledge.