Question

Unable to restart or reload Nginx

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)

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

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

sudo fuser -k 443/tcp
service nginx restart

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more