By bitmap
Hi all,
I just installed Nginx but when I try to start it it fails with the following error:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
If I check the status I get the following output:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/nginx.service.d
└─override.conf
Active: failed (Result: exit-code) since Mon 2020-06-08 15:59:32 UTC; 5min ago
Docs: man:nginx(8)
Process: 3839 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=2)
Process: 3816 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
Process: 25445 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Process: 25435 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 3813 (code=exited, status=0/SUCCESS)
Jun 08 15:59:30 ubuntu nginx[25445]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 08 15:59:30 ubuntu nginx[25445]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jun 08 15:59:31 ubuntu nginx[25445]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 08 15:59:31 ubuntu nginx[25445]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jun 08 15:59:31 ubuntu nginx[25445]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jun 08 15:59:31 ubuntu nginx[25445]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jun 08 15:59:32 ubuntu nginx[25445]: nginx: [emerg] still could not bind()
Jun 08 15:59:32 ubuntu systemd[1]: nginx.service: Control process exited, code=exited status=1
Jun 08 15:59:32 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'.
Jun 08 15:59:32 ubuntu systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Does anyone have any ideas why Nginx would not start?
Thanks!
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
Hi there @bitmap,
It would usually mean that you have another service running on the same port. And note that you can not have multiple services listening on the same port.
The service which is already listening on port 80 might be Apache or any other web server listening on port 80.
To check that, you could run the following command:
- sudo netstat -plant | grep 80
This would show you which service exactly is listening on port 80 and you can then make a decision if you want to have that service as it is or have Nginx instead of it.
If this is indeed Apache, you would need to make a decision whether you want to use Apache or Nginx.
If you want to only have Nginx you have to stop Apache first:
- sudo systemctl stop apache2
And then start Nginx:
- sudo systemctl start nginx
If you would like to have Apache and Nginx together, you can follow the steps here on how to setup Nginx as a reverse proxy for Apache:
Another thing that I could recommend is checking the answer here on how to troubleshoot common Nginx problems:
And here is also a quick video demo on how to troubleshoot such issues as well:
I hope that this helps and let me know if you have any other questions!
Regards, Bobby
Hey @bitmap,
The error that you are showing means that the port 80 is being used by another service. You can check what is taking the port with netstat -tulpn | grep 80 . After you see what is taking the port, you can either stop the service or kill the process with kill -process id- .
I hope this helps!
Best regards,
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.