Why doesn't this IPv6 listen directive also accept IPv4?

lwood asked:

In my nginx (1.4.2) setup on Ubuntu 12.04, I have set up only one configuration file (I deleted/disabled the others):

server {
  listen [::]:80 default_server;

  location / {
    root /home/lwood/websites/default/public;
  }
}

I have restarted nginx.

Why does nginx not accept IPv4 connections? Here are the docs

http://wiki.nginx.org/HttpCoreModule#listen

They mention that

In Linux by default any IPv6 TCP socket also accepts IPv4 traffic … the runtime parameter: net.ipv6.bindv6only which has the value 0 by default.

I have checked with sysctl, bindv6only is indeed set to 0. So my IPv6 listen directive should accept IPv4 as well, right?

I must be misunderstanding the docs. An explanation would be appreciated.

My answer:


The wiki is out of date. As specified in the actual documentation, the default for ipv6only is on since nginx 1.3.4. If you omit the parameter, then nginx will only bind to IPv6. The OS settings are never used.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.