# How to bind nginx to ipv4 and ipv6 interface?

**URL:** <https://www.ruby-forum.com/t/how-to-bind-nginx-to-ipv4-and-ipv6-interface/224802>\
**Category:** NGINX\
**Created:** [November 26, 2012, 10:51pm UTC](https://www.ruby-forum.com/t/how-to-bind-nginx-to-ipv4-and-ipv6-interface/224802 "2012-11-26T22:51:08Z")\
**Posts on this page:** 5\
**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:** [November 26, 2012, 10:51pm UTC](https://www.ruby-forum.com/t/how-to-bind-nginx-to-ipv4-and-ipv6-interface/224802/1 "2012-11-26T22:51:08Z")

</div>

Hello,  
any one can tell me what is wrong on my nginx 1.2.5 version compied with  
ipv6 suppot ? I try to start nginx on both ipv4 and ipv6. I read on  
internet  
if I put in my config file: listen [::]:80; is enought and nginx will  
bind  
on both ipv4 and ipv6 interfaces or even if I compile nginx with ipv6  
support is enought and on listen 80; will bind to ip4 and ip6, but i  
receive  
follow error:

[emerg] 15728#0: bind() to [::]:80 failed (98: Address already in use

Any hints how to start nginx on both intefaces ?

Posted at Nginx Forum:

> **[How to bind nginx to ipv4 and ipv6 interface ?](https://forum.nginx.org/read.php?2,233246,233246#msg-233246)**
>
> Hello, any one can tell me what is wrong on my nginx 1.2.5 version compied with ipv6 suppot ? I try to start nginx on both ipv4 and ipv6. I read on internet if I put in my config file: listen \[::\]:80; is enought and nginx will bind on both ipv4 and...

---

<div class="post-metadata">

**Author:** ![hristoc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8edcca/32.png) [@hristoc](https://www.ruby-forum.com/u/hristoc)\
**Post date:** [December 19, 2012, 7:26pm UTC](https://www.ruby-forum.com/t/how-to-bind-nginx-to-ipv4-and-ipv6-interface/224802/2 "2012-12-19T19:26:13Z")

</div>

Any one ?

Posted at Nginx Forum:

> **[Re: How to bind nginx to ipv4 and ipv6 interface ?](https://forum.nginx.org/read.php?2,233246,234206#msg-234206)**
>
> Hello, any one can tell me what is wrong on my nginx 1.2.5 version compied with ipv6 suppot ? I try to start nginx on both ipv4 and ipv6. I read on internet if I put in my config file: listen \[::\]:80; is enought and nginx will bind on both ipv4 and...

---

<div class="post-metadata">

**Author:** ![hristoc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8edcca/32.png) [@hristoc](https://www.ruby-forum.com/u/hristoc)\
**Post date:** [December 19, 2012, 7:32pm UTC](https://www.ruby-forum.com/t/how-to-bind-nginx-to-ipv4-and-ipv6-interface/224802/3 "2012-12-19T19:32:03Z")

</div>

Multiple listen statements

---

<div class="post-metadata">

**Author:** ![hristoc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8edcca/32.png) [@hristoc](https://www.ruby-forum.com/u/hristoc)\
**Post date:** [December 20, 2012, 9:29am UTC](https://www.ruby-forum.com/t/how-to-bind-nginx-to-ipv4-and-ipv6-interface/224802/4 "2012-12-20T09:29:51Z")

</div>

> listen 80;  
> listen [::]:80 ipv6only=on;

Remember that ipv6only is a socket option, and you can specify a socket  
option  
only once per address:port pair:

> A listen directive can have several additional parameters specific to  
> socket-related system calls. They can be specified in any listen  
> directive, but only once for the given address:port pair.

So your config needs to look this way, if you have multiple server  
statements in your config:

---

<div class="post-metadata">

**Author:** ![hristoc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8edcca/32.png) [@hristoc](https://www.ruby-forum.com/u/hristoc)\
**Post date:** [December 19, 2012, 8:02pm UTC](https://www.ruby-forum.com/t/how-to-bind-nginx-to-ipv4-and-ipv6-interface/224802/5 "2012-12-19T20:02:26Z")

</div>

On Nov 27, 2012, at 1:50 , hristoc wrote:

> Any hints how to start nginx on both intefaces ?

listen 80;  
listen [::]:80 ipv6only=on;

–  
Igor S.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.
