Can’t get Nginx to work on port 80. Works fine on any other port
Solution 1
Rebooted OSX. Worked. I think with linux would be different.
Solution 2
The error is as follows:
2015/10/10 17:16:19 [emerg] 23906#0: bind() to 0.0.0.0:80 failed (48: Address already in use)
That “Address already in use” says it all: Something else on your system is using port 80. Do you have web sharing enabled or perhaps Apache installed and running? The way you can check this is to run lsof
like this on your system:
sudo lsof -i -P | grep -i "80"
That will strictly show you what process might be using port 80. If you are curious to see what other ports are set to “listen” on your Mac OS X system just run this command:
sudo lsof -i -P
Related videos on Youtube
Ariel Nonamë
Updated on September 18, 2022Comments
-
Ariel Nonamë over 1 year
I’ve just setup Homebrew’s Nginx on Mac OS X 10.11 (El Capitan).
If I set my Ngnix config like this:
listen 127.0.0.1:8080; listen 127.0.0.1:81; listen 127.0.0.1:75;
It’ll work. But If I put this in there:
listen 127.0.0.1:80;
It wont. I’ll get connection refused if I go
http://127.0.0.1
ps
says Nginx is running, butnetstat -a | grep nginx
ornetstat -a | grep 80
says it isn't.Running this as root, of course (not that I need that for running on
:8080
And Mac OS X Firewall’s not running.
Error log doesn’t show this anymore anymore:
2015/10/10 17:16:19 [emerg] 23906#0: bind() to 0.0.0.0:80 failed (48: Address already in use)
Any ideas? I CAN work with this running on
8080
(curiously, when I run on8080
, it opens the80
port and redirects it to80
).-
dwkns about 8 yearsThis can happen if you have previously installed pow pow.cx it adds a pfctl rule that forwards all traffic on port 80 to the pow port. Uninstalling pow fixes the problem. It is possible to get both ngrix and pow running together but it's a little fiddly.
-
-
Peshraw H. Ahmed almost 6 yearsSometimes we really should think simple. After 1 hour of problem I saw this and worked :)
-
ankush981 almost 4 yearsRestarting nginx doesn't help on MacOS.