1

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/

knuckfubuck
  • 113
  • 1
  • 6

4 Answers4

2

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.

LukeR
  • 3,086
  • 2
  • 29
  • 25
  • 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 05: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 07:13
1

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

Alex
  • 7,789
  • 4
  • 36
  • 51
1

netstat -plan

will provide you the process name then use killall -9

and restart you nginx

sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
Sim
  • 9
  • 1
0

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

Matt
  • 1