Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using nginx 1.4.1 (now, before it was 1.2.1) and would like to support dual stack (IPv4 and IPv6). I'm always getting duplicate listen options for xyz errors from nginx.

server {
    listen 80 default_server;
    listen [::]:80 ipv6only=on default_server;
    server_name domain1;
server {
    listen 443 ssl default_server;
    listen [::]:443 ssl ipv6only=on default_server;
    server_name domain1;

server {
    listen 80;
    listen [::]:80 ipv6only=on;
    server_name domain2;
server {
    listen 443 ssl;
    listen [::]:443 ssl ipv6only=on;
    server_name domain2;

If I use only listen 80 I'm getting only IPv4. Otherwise if I use listen [::]:80 I'm getting only IPv6.

How to setup nginx 1.4.x to support virtual host dual stack?

share|improve this question
Use this to find out if it's binding correctly netstat -nlp | grep nginx – CMCDragonkai Jun 11 '14 at 8:46
up vote 6 down vote accepted

You've used default_server in more than one server block. This is only meant to be used to define the default virtual host for a given IP address/port combination. So it should appear only once per IP/port pair in your entire configuration. Which host should be the default virtual host is up to you. (Or you did, until you edited this part out.)

Also, ipv6only can appear only once in the entire configuration. Since its default in 1.4 and higher is on, you can safely omit it entirely.

share|improve this answer
Removing ipv6only solved the problem. Strange error behaviour. – burnersk Sep 1 '13 at 19:02

Your Answer


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.