Upgrade troubles: nginx: [emerg] bind() to [::]:80 failed

Just did an apt-get update and upgrade on my ubuntu LEMP:

First got messages that it wanted to overwrite default and nginx.conf files, which I refused. Which resulted in

2012/03/15 20:36:05 [emerg] 19842#0: unknown "https" variable

Got this error previous time as well. Then I had to add the following to the nginx.conf:

map $scheme $server_https {
    default off;
    https on;
}

After which my server run happily ever after, until now.

This time I had to comment the https variable in the fastcig_params file to get past this. But now my nginx refuses to restart because of this:

2012/03/15 21:09:58 [emerg] 9599#0: bind() to [::]:80 failed (98: Address already in use)
2012/03/15 21:09:58 [emerg] 9599#0: bind() to [::]:80 failed (98: Address already in use)
2012/03/15 21:09:58 [emerg] 9599#0: bind() to [::]:80 failed (98: Address already in use)
2012/03/15 21:09:58 [emerg] 9599#0: bind() to [::]:80 failed (98: Address already in use)
2012/03/15 21:09:58 [emerg] 9599#0: bind() to [::]:80 failed (98: Address already in use)
2012/03/15 21:09:58 [emerg] 9599#0: still could not bind()

I don't have apache running. There are no nginx processes running. This is really annoying, second time that nginx breaks during upgrade.

The command netstat -ltnp returned following output:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      2181/mysqld     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2053/sshd       
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      2458/master     
tcp6       0      0 :::4949                 :::*                    LISTEN      2186/munin-node 
tcp6       0      0 :::22                   :::*                    LISTEN      2053/sshd     

What is going on?

2 Replies

In a final act of despair I removed all sites (sudo rm *) form the sites-enabled directory.

Then I made a link to my previous default vhost config. Problem persists.

Then I made a link to the new default vhost config (came with the upgrade). IT WORKZ!!!

Difference: in the new config file the line to listen for ipv6 on port 80 is commented out

#listen   [::]:80 default ipv6only=on; ## listen for ipv6

My server is ipv6 enabled, so is nginx, it worked before, now it doesn't. Anyway, I am bringing my sites online again by adding a # before the listen [::]:80 line in the vhost config files.. Very :D man. Problem solved, at least workaround. No clue as to why problem occurred, and how to make my sites ipv6 ready.

All the gory details are listed in http://wiki.nginx.org/HttpCoreModule#listen

I didn't really read through all of it, but having this line for only one vhost:

listen [::]:80 ipv6only=on default;

and only this for the other vhosts:

listen [::]:80;

seems to solve the problem.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct