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.

When I reboot my server (not nginx, the whole server), Nginx fails to start automatically. After I logged into the server, I can start nginx manually (service nginx start). It works. But if I restart again, I have to manually start Nginx. When checking the error.log for Nginx, I saw this error repeated several times :

2012/08/27 09:19:23 [emerg] 1066#0: bind() to [ipv6]:80 failed (99: Cannot assign requested address)

How can I fix this? What is this problem? (Im running an Ubuntu 12.04 server)

share|improve this question
    
1. ifconfig? 2. grep listen /path/to/nginx.conf? –  quanta Aug 27 '12 at 4:10
    
@quanta added the outputs :) –  EApubs Aug 27 '12 at 4:47
add comment

2 Answers

up vote 2 down vote accepted

bind() to [ipv6]:80 failed (99: Cannot assign requested address)

It sounds like your IPv6 address has just been assigned to eth0, and still be in the tentative state, thus Nginx cannot establish a listen on that IP.

Either turn of DAD (Duplicate Address Detection) by running:

sysctl -w net.ipv6.conf.eth0.dad_transmits=0

(insert into /etc/sysctl.conf for permanent)

or add this line into /etc/network/interfaces, under inet6 interface definition

post-up while ip -6 addr show tentative | grep . > /dev/null ; do sleep 1 ; done

Source: http://pyro.eu.org/how-to/micro/nginx-cannot-assign-requested-address-ipv6.txt

share|improve this answer
    
Thanks. What will be the best option out of the two? I also included the interfaces file on my server (please check the above question) –  EApubs Aug 27 '12 at 5:25
1  
I think option 2 is better. –  quanta Aug 27 '12 at 5:34
    
Perfect! It worked! Thanks a lot :) –  EApubs Aug 27 '12 at 6:04
add comment

I had similar symptoms, but a different configuration. The server runs Debian Wheezy with static IPv4 and IPv6 address configured.

# /etc/network/interfaces
auto lo eth0
iface lo inet loopback

iface eth0 inet static
 address 192.0.2.3
 netmask 255.255.255.0
 gateway 192.0.2.1

iface eth0 inet6 static
 address 2001:db8::3
 netmask 64
 gateway 2001:db8::1        

At every boot, nginx failed to start:

bind() to [2001:db8::3]:80 failed (99: Cannot assign requested address)

Manually starting works fine and manual inspection also showed that the addresses and routes are set. Just setting the IPv6 address in interfaces (without the IPv4 address) worked. Removing the static IPv6 gateway also worked, but then a link-local gateway address is used. After further debugging, I found that the boot process would spit out:

RTNETLINK answers: File exists
Failed to bring up eth0.

It turns out that an IPv6 address and gateway is automatically assigned by the router when the interface is brought up. To avoid this behavior, set accept_ra 0 in the iface eth0 inet6 section. The inet6 section has also to be moved before the inet section or the default route will still point to the link-local address.

share|improve this answer
add comment

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.