Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 failed (98: Address already in use)
nginx: [emerg] bind() to failed (98: Address already in use)
nginx: [emerg] bind() to failed (98: Address already in use)
nginx: [emerg] bind() to failed (98: Address already in use)
nginx: [emerg] bind() to 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.


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    *               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    
share|improve this question
What does sudo netstat -ltnp tell you? –  womble Sep 5 '11 at 3:30
@womble anything else you need? –  Noah Clark Sep 5 '11 at 3:41
Go to command console, type this: "netstat -a" and post the results. –  U4iK_HaZe Sep 5 '11 at 7:08
What user are you trying to start nginx as? (the master process, not the workers) –  Martin Fjordvald Sep 5 '11 at 11:26
@Martin, I assume I'm doing it as root. I'm starting it via: "sudo /etc/init.d/nginx start" –  Noah Clark Sep 5 '11 at 12:42
add comment

1 Answer

up vote 7 down vote accepted

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.

share|improve this answer
This is correct. I have two http statements. I commented out one of them and now it starts. –  Noah Clark Sep 5 '11 at 12:54
Note 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. –  Azendale Mar 1 '13 at 4:40
For 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. –  badcat Mar 21 '13 at 15:17
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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