62

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.

1

10 Answers 10

82

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.

29

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

5
  • how can we access both IIS and nginx with 80 port, because i required both. if that is not possible suggest me that how can we access an application without port number like for example we nginx is listening on port 8080 then the url is "localhost:8080". instead of that i want to access like www.somename.com @Vishal R
    – Midhunsai
    Aug 19, 2020 at 15:56
  • you cannot run two servers on single port simultaneously. Start IIS on different port and then reverse proxy it using nginx. refer this: docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy
    – Vishal R
    Aug 19, 2020 at 20:22
  • @Midhunsai hope this helps!
    – Vishal R
    Aug 20, 2020 at 16:42
  • 1
    netsh http add iplisten ipaddress=:: what does this command do?
    – Sam Sirry
    Oct 10, 2020 at 11:52
  • 1
    You should also include a simple explanation for the command instead of "run this and it works".
    – cdalxndr
    Nov 22, 2020 at 20:52
9
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...!!

2
  • 1
    That may solve the problem but i recommend you to change the port at nginx.conf because if you restart your pc, you need always to stop it Jan 29, 2020 at 4:43
  • You can mark the "World Wide Web Publishing" service to Start Manually, so that IIS does not start on restart.
    – Adarsha
    Feb 23, 2021 at 18:03
8

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.

1
  • Sorry for not mentioning the details about operating system. I am using windows and running command prompt as administrator. Please provide any way to solve this on windows. Thanks rodolk.
    – Sagar
    Sep 20, 2016 at 8:45
5

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

1
4

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

2

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"]
1

For future Googlers:

My problem was with port 443 when using nginx with ssl. I figured out that xampp was automatically running it's apache, mysql, and filezilla via system services. After uninstalling xampp, the problem is solved.

0

On the folder site-avaliables, there is a file "default", change the port there: /etc/nginx/sites-available/default

for example: "server { listen 81; }"

-1

change the port to 99(c:....\nginx-1.25.3\conf\nginx.conf), it will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.