nginx can't bind to port 80..Nothing running on port 80
One possibility is that, for some reason, nginx is binding to port 80 twice.
If it tries to do this it will fail. An example might be binding to IPV6 and IPV4, or binding it to public ip and the wildcard ip.
Check your nginx config to make sure that it is only binding once.
Related videos on Youtube
Comments
-
Noah Clark almost 2 years
I'm trying to setup nginx on Ubuntu 11.04. I have followed the roughly the directions found here: http://library.linode.com/frameworks/sinatra/debian-6-squeeze . I know it is for Debian, but I basically took those steps and then googled "How to do x in ubuntu 11.04" Although, I did pull the init scripts from their library.
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] still could not bind()
The command: 'sudo lsof -i:80' returns nothing running on port 80.
How do I troubleshoot this or any ideas on what maybe going wrong?
I saw Nginx + uWSGI on a fresh Ubuntu install - bind error port 80 and tried restarting the computer and running it once and I get the same error. After running it once, I then ran the lsof command.
UPDATE
sudo netstat -ltnp returns:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1998/sshd tcp6 0 0 :::22 :::* LISTEN 1998/sshd
nestat -a returns:
Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:ssh *:* LISTEN tcp 0 176 matterhorn.noahc.ne:ssh 173-26-190-206.cl:26467 ESTABLISHED tcp6 0 0 [::]:ssh [::]:* LISTEN udp 0 0 matterhorn.noahc.:35332 10504.x.rootbsd.net:ntp ESTABLISHED udp 0 0 matterhorn.noahc.:53298 tick.tadatv.com:ntp ESTABLISHED udp 0 0 matterhorn.noahc.:54371 ns1.baribault.net:ntp ESTABLISHED udp 0 0 matterhorn.noahc.:38304 tardis.chpc.utah.ed:ntp ESTABLISHED Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node Path unix 2 [ ACC ] STREAM LISTENING 684 @/com/ubuntu/upstart unix 2 [ ] DGRAM 730 @/org/kernel/udev/udevd unix 6 [ ] DGRAM 4316 /dev/log unix 2 [ ] DGRAM 11447 unix 3 [ ] STREAM CONNECTED 10466 unix 3 [ ] STREAM CONNECTED 10465 unix 2 [ ] DGRAM 11411 unix 3 [ ] STREAM CONNECTED 2958 unix 3 [ ] STREAM CONNECTED 2957 unix 2 [ ] DGRAM 4518 unix 2 [ ] DGRAM 2902 unix 2 [ ] DGRAM 2614 unix 3 [ ] STREAM CONNECTED 1284 @/com/ubuntu/upstart unix 3 [ ] STREAM CONNECTED 4131 unix 3 [ ] DGRAM 733 unix 3 [ ] DGRAM 732 unix 3 [ ] STREAM CONNECTED 1038 @/com/ubuntu/upstart unix 3 [ ] STREAM CONNECTED 2088
-
womble almost 13 yearsWhat does
sudo netstat -ltnp
tell you? -
Noah Clark almost 13 years@womble anything else you need?
-
U4iK_HaZe almost 13 yearsGo to command console, type this: "netstat -a" and post the results.
-
Martin Fjordvald almost 13 yearsWhat user are you trying to start nginx as? (the master process, not the workers)
-
Noah Clark almost 13 years@Martin, I assume I'm doing it as root. I'm starting it via: "sudo /etc/init.d/nginx start"
-
-
Noah Clark almost 13 yearsThis is correct. I have two http statements. I commented out one of them and now it starts.
-
Azendale over 11 yearsNote that you can bind to IPv4 and IPv6 at the same time. You can do this with
listen [::]:80;
syntax. I also had the problem of two things binding to port 80 on the same address family and it was because I had two conflicting server statements. -
BastiBen over 11 yearsFor me it was trying to bind to IPv6, which is not correctly configured. After commenting out the
listen [::]:80;
it was fine. Seems to be included in nginx' stock configuration files now.