nginx upgrade fails due bind error on 127.0.0.1 in a FreeBSD jail

Steven Hartland steven.hartland at multiplay.co.uk
Sun Dec 4 21:39:59 UTC 2016


We've used nginx for years and never had an issue with nginx upgrade 
until today where the upgrade command ran but almost instantly after the 
new process exited.

/usr/local/etc/rc.d/nginx upgrade
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Upgrading nginx binary:
Stopping old binary:

In the default nginx log we had:
2016/12/04 21:18:22 [emerg] 25435#0: bind() to 127.0.0.1:81 failed (48: 
Address already in use)
nginx: [emerg] bind() to 127.0.0.1:81 failed (48: Address already in use)
2016/12/04 21:18:22 [emerg] 25435#0: bind() to 127.0.0.1:81 failed (48: 
Address already in use)
nginx: [emerg] bind() to 127.0.0.1:81 failed (48: Address already in use)
2016/12/04 21:18:22 [emerg] 25435#0: bind() to 127.0.0.1:81 failed (48: 
Address already in use)
nginx: [emerg] bind() to 127.0.0.1:81 failed (48: Address already in use)
2016/12/04 21:18:22 [emerg] 25435#0: bind() to 127.0.0.1:81 failed (48: 
Address already in use)
nginx: [emerg] bind() to 127.0.0.1:81 failed (48: Address already in use)
2016/12/04 21:18:22 [emerg] 25435#0: bind() to 127.0.0.1:81 failed (48: 
Address already in use)
nginx: [emerg] bind() to 127.0.0.1:81 failed (48: Address already in use)
2016/12/04 21:18:22 [emerg] 25435#0: still could not bind()
nginx: [emerg] still could not bind()

Running the start just after resulted in a running version but is 
obviously unexpected to have upgrade result in a failure.

I believe the change to add a localhost bind to the server in question 
was relatively recent so I suspect it has something to do with that.

The config for this is simply:
server {
     listen 127.0.0.1:81;
     server_name localhost;

     location /status {
         stub_status;
     }
}

The upgrade in this case was:
nginx: 1.10.1_1,2 -> 1.10.2_2,2

Now this server is running under FreeBSD in a jail (10.2-RELEASE) and it 
has 127.0.0.1 available yet it seems nginx has incorrectly bound the 
address:
netstat -na | grep LIST | grep 81
tcp4       0      0 10.10.96.146.81        *.* LISTEN

sockstat | grep :81
www      nginx      25666 25 tcp4   10.10.96.146:81       *:*
www      nginx      25665 25 tcp4   10.10.96.146:81       *:*
www      nginx      25664 25 tcp4   10.10.96.146:81       *:*
www      nginx      25663 25 tcp4   10.10.96.146:81       *:*
www      nginx      25662 25 tcp4   10.10.96.146:81       *:*
www      nginx      25661 25 tcp4   10.10.96.146:81       *:*
www      nginx      25660 25 tcp4   10.10.96.146:81       *:*
www      nginx      25659 25 tcp4   10.10.96.146:81       *:*
www      nginx      25658 25 tcp4   10.10.96.146:81       *:*
www      nginx      25657 25 tcp4   10.10.96.146:81       *:*
www      nginx      25656 25 tcp4   10.10.96.146:81       *:*
www      nginx      25655 25 tcp4   10.10.96.146:81       *:*
www      nginx      25654 25 tcp4   10.10.96.146:81       *:*
www      nginx      25653 25 tcp4   10.10.96.146:81       *:*
www      nginx      25652 25 tcp4   10.10.96.146:81       *:*
www      nginx      25651 25 tcp4   10.10.96.146:81       *:*
root     nginx      25650 25 tcp4   10.10.96.146:81       *:*

ifconfig lo0
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
         options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
         inet 127.0.0.1 netmask 0xffffffff

So it looks like nginx is incorrectly binding which is resulting in the 
issue with upgrade.

Anyone seen this before?

I've confirmed nginx is responding correctly on 127.0.0.1:
lwp-request http://127.0.0.1:81/status
Active connections: 1077
server accepts handled requests
  31516 31516 90387
Reading: 0 Writing: 5 Waiting: 1071

     Regards
     Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20161204/87975793/attachment.html>


More information about the nginx mailing list