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 know this is a common problem usually having to do with apache or another service already running on port 80 and I have done a lot of searching and running netstat and still have not figured out why I am getting this error.

I rebuilt my slice, did a fresh install of Ubuntu 10.04 and setup nginx + uwsgi. It worked and I was able to see my Django site. I then installed Postgres8.4 and the rest of the stack needed for Geodjango from this link.

After that was done I tried to restart nginx and I get this error:

sudo /etc/init.d/nginx start
Starting nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: still could not bind()

I have nginx set to listen 80. Here's an output from netstat -l --numeric-ports | grep 80:

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN

Output from sudo lsof +M -i4:

nginx    2330     root    8u  IPv4   3195      0t0  TCP *:www (LISTEN)
nginx    2331 www-data    8u  IPv4   3195      0t0  TCP *:www (LISTEN)
uwsgi    2335        s    4u  IPv4   3259      0t0  TCP localhost:8000 (LISTEN)
uwsgi    2352        s    4u  IPv4   3259      0t0  TCP localhost:8000 (LISTEN)
uwsgi    2353        s    4u  IPv4   3259      0t0  TCP localhost:8000 (LISTEN)
uwsgi    2354        s    4u  IPv4   3259      0t0  TCP localhost:8000 (LISTEN)
uwsgi    2355        s    4u  IPv4   3259      0t0  TCP localhost:8000 (LISTEN)

Anyone have any other ideas how I can figure out what is blocking port 80?

edit

Paste of my /etc/init.d/nginx script here: http://dpaste.com/hold/400937/

share|improve this question

4 Answers 4

up vote 2 down vote accepted

Shouldn't you have issued restart as an argument to your init script?

I would expect

sudo /etc/init.d/nginx start

to complain if nginx was already running. Which it sounds like it was.

share|improve this answer
    
you are correct. Once I got fuser installed it is showing 2 nginx running on port 80 with PID 2381 and 2382. When I kill them with fuser I am able to restart once without the bind error and then it comes up again. I set worker_processes 1; I edited my post above and pasted the /etc/init.d/nginx script I am using. Maybe the problem is there? –  knuckfubuck Feb 10 '11 at 5:26
    
@knuckfubuck if you just want nginx to pick up changes you made to nginx conf files (like you added new site) do reload –  Art Shayderov Feb 10 '11 at 7:13

fuser -n tcp 80 will show you a PID of process using port 80.

share|improve this answer
    
I get fuser "command not found". sudo fuser gives the same result. –  knuckfubuck Feb 9 '11 at 2:58
    
You should install it using this: apt-get install psmisc –  Alex Feb 9 '11 at 10:01
    
thank you. –  knuckfubuck Feb 10 '11 at 5:33

netstat -plan

will provide you the process name then use killall -9

and restart you nginx

share|improve this answer

I would suggest that you paste your actual config files from /etc/nginx/sites-enabled.. Also you might try to be more explicit about the IP addresses you are binding to.

Recently I have experienced strangeness with nginx (8.54) and uWsgi (.96) on Ubuntu 10.10 KVM node servers. I employed non local address binding combined with VLAN/bonding 802.3ad and bridging so the setup is similar in theory to a "slice" from your provider. My hunch was that it was related to nginx, although the underlying layers in Ubuntu have been going through tremendous changes as well ..

I would suggest being as explicit as possible when configuring nginx. Especially in an environment with multiple IP's or aliased IP addresses on an a single interface.

http://linux-ip.net/html/adv-nonlocal-bind.html

share|improve this answer

Your Answer

 
discard

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.