Nginx- error: bind() to 0.0.0.0:80 failed. permission denied

NetworkingNginxLocalhostPort

Networking Problem Overview


I am trying to run Nginx, but I am getting the error below:

> bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a > socket in a way forbidden by its access permissions)

Please provide some help on what changes I need to do to make it working?

I have tried running on ports other than 80 and it works. but I need it to be running on 80.

Note: I am running on Windows 7 with command prompt running as Administrator.

Networking Solutions


Solution 1 - Networking

If the port is already in use, you can change the default port of 80 to a different port that is not in use (maybe 8070). In conf\nginx.conf:

server {
    listen       8070;
    ...
}

After startup, you should be able to hit localhost:8070.

Solution 2 - Networking

tl;dr

netsh http add iplisten ipaddress=::

Faced similar issue. Run the above command in command prompt.
This should free up port 80, and you'd be able to run nginx.

Description:
netsh http commands are used to query and configure HTTP.sys settings and parameters.

add iplisten : Adds a new IP address to the IP listen list, excluding the port number.
"::" means any IPv6 address.

For more netsh http commands refer the netsh http commands documentation.

Hope this helps!!

Solution 3 - Networking

You have to be admin or root to bind port 80. Something you can do if you cannot run as root, is that your application listens to other port, like 8080, and then you redirect messages directed to 80 to 8080. If you are using Linux you redirect messages with iptables.

Solution 4 - Networking

nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)

I got a similar problem, My 80 port was listening to IIS (windows machine). Stopping IIS freed up 80 port.

The problem got resolved...!!

Solution 5 - Networking

Please check if another Proxy is running under port 80 ---> in my case IIS was running as a reverse proxy, so nginx could not start..

Stopping IIS, and starting of NGXIN solved the problem

Solution 6 - Networking

My Tomcat server was running on port 80. Changed the port number in conf\nginx.conf file and it started to work.

Solution 7 - Networking

This is an old question but since I had this problem recently I thought of posting another possible reason in this problem.

If the user is using Docker and has already tried all proposed solutions as stated above and is wondering why port 80 is trying to bind although on your configurations you are overwriting the port to non root port e.g. listen 8080; it seems that the newer NGINX images have a default nginx.conf file in /etc/nginx/conf.d.

Sample:

$ grep -r 80 /etc/nginx/
/etc/nginx/conf.d/default.conf:    listen       80;

On my case I removed it on my Dockerfile:

RUN set -x \
        && rm -f /etc/nginx/nginx.conf \
        && rm -f /etc/nginx/conf.d/default.conf

Next step pass from my custom configurations:

COPY ["conf/nginx.conf", "/etc/nginx/nginx.conf"]

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSagarView Question on Stackoverflow
Solution 1 - NetworkingDaniel TreiberView Answer on Stackoverflow
Solution 2 - NetworkingVishal RView Answer on Stackoverflow
Solution 3 - NetworkingrodolkView Answer on Stackoverflow
Solution 4 - NetworkingSurya VenkatapathiView Answer on Stackoverflow
Solution 5 - NetworkingMili BeView Answer on Stackoverflow
Solution 6 - NetworkingpavithraCSView Answer on Stackoverflow
Solution 7 - NetworkingThanosView Answer on Stackoverflow