# Startup error -\> "duplicate listen options" if 2nd IPv6 listener is enabled

**URL:** <https://www.ruby-forum.com/t/startup-error-duplicate-listen-options-if-2nd-ipv6-listener-is-enabled/221175>\
**Category:** NGINX\
**Created:** [July 3, 2012, 7:40pm UTC](https://www.ruby-forum.com/t/startup-error-duplicate-listen-options-if-2nd-ipv6-listener-is-enabled/221175 "2012-07-03T19:40:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 3, 2012, 7:40pm UTC](https://www.ruby-forum.com/t/startup-error-duplicate-listen-options-if-2nd-ipv6-listener-is-enabled/221175/1 "2012-07-03T19:40:52Z")

</div>

I run src-built nginx/1.3.2 on linux/64.

I have two nginx vhosts enabled:  
site 1)  
…  
server {  
server\_name test1.loc;  
listen 10.0.0.1:443;  
listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;  
…

site 2)  
…  
server {  
server\_name test2.loc;  
listen 10.0.0.1:443 default;  
# listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;  
…[code]

With this config, if I start nginx,

service nginx start  
Shutting down nginx done  
Starting nginx done

all’s well.

But, if for site 2) I enable the IPv6 listener,

- 
# listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;

- listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;

Now, @ nginx start,

service nginx start  
Starting nginx nginx: [emerg] duplicate listen options for  
[2001:xxx:xxxx:xxx::1]:443 in  
/usr/local/etc/nginx/sites-enabled/test2.loc.conf:21  
startproc: exit status of parent of /usr/local/sbin/nginx: 1

```
                             failed

```

Is this a bug, feature or config problem?

Thanks.

Posted at Nginx Forum:

> **[startup error -\> "\[emerg\] duplicate listen options" if 2nd IPv6 listener...](https://forum.nginx.org/read.php?2,228250,228250#msg-228250)**
>
> I run src-built nginx/1.3.2 on linux/64. I have two nginx vhosts enabled: site 1) ... server { server\_name test1.loc; listen 10.0.0.1:443; listen \[2001:xxx:xxxx:xxx::1\]:443 ipv6only=on; ... site

---

<div class="post-metadata">

**Author:** ![pgn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c2a13f/32.png) [@pgn](https://www.ruby-forum.com/u/pgn)\
**Post date:** [July 3, 2012, 8:03pm UTC](https://www.ruby-forum.com/t/startup-error-duplicate-listen-options-if-2nd-ipv6-listener-is-enabled/221175/2 "2012-07-03T20:03:05Z")

</div>

Today Jul 3, 2012 at 13:39 pgn wrote:

> [2001:xxx:xxxx:xxx::1]:443 in  
> /usr/local/etc/nginx/sites-enabled/test2.loc.conf:21  
> startproc: exit status of parent of /usr/local/sbin/nginx: 1
> 
> ```
> failed
> 
> ```
> 
> Is this a bug, feature or config problem?

[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#listen)  
A listen directive can have several additional parameters specific to  
system calls listen() and bind(). They can be specified in any listen  
directive, but only once for the given address:port pair.

–  
WNGS-RIPE

---

<div class="post-metadata">

**Author:** ![pgn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c2a13f/32.png) [@pgn](https://www.ruby-forum.com/u/pgn)\
**Post date:** [July 3, 2012, 8:13pm UTC](https://www.ruby-forum.com/t/startup-error-duplicate-listen-options-if-2nd-ipv6-listener-is-enabled/221175/3 "2012-07-03T20:13:01Z")

</div>

Sorry, I don’t understand your point.

## Why is this ok, and fully functional?

## server { server\_name test1.loc; listen 10.0.0.1:443; … server {server\_name test2.loc; listen 10.0.0.1:443; …

## but this is not?

server { server\_name test1.loc;  
listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;  
…  
server {server\_name test2.loc;  
listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;  
…

---

<div class="post-metadata">

**Author:** ![pgn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c2a13f/32.png) [@pgn](https://www.ruby-forum.com/u/pgn)\
**Post date:** [July 3, 2012, 8:35pm UTC](https://www.ruby-forum.com/t/startup-error-duplicate-listen-options-if-2nd-ipv6-listener-is-enabled/221175/4 "2012-07-03T20:35:14Z")

</div>

Today Jul 3, 2012 at 14:12 pgn wrote:

> * * *

listen directive without additional parameters.

> ## but this is not?
> 
> ## server { server\_name test1.loc; listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on; … server {server\_name test2.loc; listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on; …

Additional parameters specified twice.

> In BOTH cases, BOTH server{} are listening on the same address:port,  
> differentiated by server\_name for vhost redirection.

Additional parameters can be specified only once for the given  
address:port pair.

–  
WNGS-RIPE

---

<div class="post-metadata">

**Author:** ![pgn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c2a13f/32.png) [@pgn](https://www.ruby-forum.com/u/pgn)\
**Post date:** [July 3, 2012, 9:05pm UTC](https://www.ruby-forum.com/t/startup-error-duplicate-listen-options-if-2nd-ipv6-listener-is-enabled/221175/5 "2012-07-03T21:05:02Z")

</div>

Done.

Reading the docs, it’s not clear to me – or others apparently:

[Name-Based Virtual Hosts With nginx on IPv6 | Kromey's Adventures](http://kromey.us/2011/06/named-based-virtual-hosts-with-nginx-on-ipv6-423.html)  
[nginx name-based virtual hosts on IPv6 - Server Fault](http://serverfault.com/questions/277653/nginx-name-based-virtual-hosts-on-ipv6)

– that ipv6only=on can only be specified once …

While some ‘additional parameters’ on the listen line are restricted in  
this manner, others – e.g., ssl, spdy – are not, and can appear  
multiple times.

Posted at Nginx Forum:

> **[Re: startup error -\> "\[emerg\] duplicate listen options" if 2nd IPv6...](https://forum.nginx.org/read.php?2,228250,228257#msg-228257)**
>
> I run src-built nginx/1.3.2 on linux/64. I have two nginx vhosts enabled: site 1) ... server { server\_name test1.loc; listen 10.0.0.1:443; listen \[2001:xxx:xxxx:xxx::1\]:443 ipv6only=on; ... site

---

<div class="post-metadata">

**Author:** ![pgn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c2a13f/32.png) [@pgn](https://www.ruby-forum.com/u/pgn)\
**Post date:** [July 3, 2012, 9:24pm UTC](https://www.ruby-forum.com/t/startup-error-duplicate-listen-options-if-2nd-ipv6-listener-is-enabled/221175/6 "2012-07-03T21:24:21Z")

</div>

Today Jul 3, 2012 at 15:04 pgn wrote:

> this manner, others – e.g., ssl, spdy – are not, and can appear  
> multiple times.

You should read docs more careful.  
[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#listen)  
ssl this parameter (0.7.14) does not relate to system calls listen()  
and bind(),  
but allows to specify that all connections accepted on this port  
should work in the SSL mode.

–  
WNGS-RIPE
