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

10

63

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.

Aletaaletha answered 20/9, 2016 at 5:57 Comment(1)
Possible duplicate of (ubuntu) nginx: [emerg] bind() to 0.0.0.0:80 failed (13: permission denied)Puklich
C
83

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.

Ceram answered 10/2, 2017 at 3:31 Comment(0)
M
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!!

Myers answered 7/5, 2020 at 21:25 Comment(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 RKarbala
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-proxyMyers
@Karbala hope this helps!Myers
netsh http add iplisten ipaddress=:: what does this command do?Isopiestic
You should also include a simple explanation for the command instead of "run this and it works".Raber
D
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...!!

Dispersoid answered 2/7, 2019 at 5:48 Comment(2)
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 itRemote
You can mark the "World Wide Web Publishing" service to Start Manually, so that IIS does not start on restart.Deceive
S
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.

Separates answered 20/9, 2016 at 7:13 Comment(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.Aletaaletha
C
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

Carapace answered 6/12, 2019 at 7:48 Comment(1)
Correct solution for me. I had apache running. ThanksSwinford
V
4

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

Vandusen answered 18/1, 2021 at 5:2 Comment(0)
R
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"]
Rede answered 29/12, 2020 at 16:55 Comment(0)
L
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.

Locarno answered 15/6, 2023 at 1:56 Comment(0)
E
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; }"

Eastnortheast answered 7/11, 2023 at 17:41 Comment(0)
S
-1

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

Stokehold answered 25/10, 2023 at 7:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.