By Milan Chheda
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)
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!
Accepted Answer
Alright. I got it fixed by running the below commands:
sudo fuser -k 443/tcp
service nginx restart
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.