Question

Nginx not starting: Address already in use (nginx: bind to 0.0.0.0:80 failed)

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!


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.

Bobby Iliev
Site Moderator
Site Moderator badge
June 9, 2020
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:

  1. 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:

  1. sudo systemctl stop apache2

And then start Nginx:

  1. 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:

https://digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-web-server-and-reverse-proxy-for-apache-on-one-ubuntu-18-04-server

Another thing that I could recommend is checking the answer here on how to troubleshoot common Nginx problems:

https://www.digitalocean.com/community/questions/how-to-troubleshoot-common-nginx-issues-on-linux-server

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,

Try DigitalOcean for free

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

Sign up

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.