Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 998
Sagar Avatar asked Sep 20 '16 05:09

Sagar


5 Answers

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.

like image 99
Daniel Treiber Avatar answered Nov 09 '22 09:11

Daniel Treiber


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!!

like image 44
Vishal R Avatar answered Nov 09 '22 09:11

Vishal R


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.

like image 8
rodolk Avatar answered Nov 09 '22 09:11

rodolk


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...!!

like image 7
Surya Venkatapathi Avatar answered Nov 09 '22 09:11

Surya Venkatapathi


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

like image 5
Mili Be Avatar answered Nov 09 '22 08:11

Mili Be