# Re:

**URL:** <https://www.ruby-forum.com/t/re/207740>\
**Category:** NGINX\
**Created:** [June 1, 2011, 6:16pm UTC](https://www.ruby-forum.com/t/re/207740 "2011-06-01T18:16:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 1, 2011, 6:16pm UTC](https://www.ruby-forum.com/t/re/207740/1 "2011-06-01T18:16:59Z")

</div>

> When running two vhosts, one of which listens on [::], the other on localhost,  
> nginx will fail with this error:  
> 2011/06/01 10:12:35 [emerg] 9750#0: bind() to 127.0.0.1:80 failed (98: Address  
> already in use)  
> My understanding was that this error stems from [::] being inclusive of  
> 127.0.0.1, causing nginx to attempt to bind it twice.  
> However, replacing the `listen localhost;` with `listen [::1];` removes the  
> error, despite the fact that [::1] is also included within [::].

I think you ran into the issue of linux binding to both ipv6 and ipv4 by  
default.  
[http://wiki.nginx.org/HttpCoreModule#listen](http://wiki.nginx.org/HttpCoreModule#listen)  
you probably want to use  
listen [::] ipv6only=on;

V/r,  
Rob

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [June 2, 2011, 12:05am UTC](https://www.ruby-forum.com/t/re/207740/2 "2011-06-02T00:05:25Z")

</div>

Yes, except that I want it to bind to both v4 and v6 for those site.  
My question was why the [::] causes it to fail to bind to 127.0.0.1, but  
works just fine with [::1], when the [::] should be binding to both of  
those in exactly the same way?

–  
Les A.

> **[akerl's blogthing](https://blog.akerl.org/)**
>
> Ramblings on open source, tea, and system administration

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [June 2, 2011, 4:34am UTC](https://www.ruby-forum.com/t/re/207740/3 "2011-06-02T04:34:48Z")

</div>

On Thu, Jun 2, 2011 at 5:05 AM, Les A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yes, except that I want it to bind to both v4 and v6 for those site.  
> My question was why the [::] causes it to fail to bind to 127.0.0.1, but works  
> just fine with [::1], when the [::] should be binding to both of those in exactly  
> the same way?

My wild guess would be because it went like this:

- nginx lookup localhost
- found two entries; ::1 and 127.0.0.1
- nginx bind to ::1
- linux’s behavior caused binding to ::1 also binds to 127.0.0.1
- nginx bind to 127.0.0.1
- already bind from previous ::1, reporting error

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [June 2, 2011, 11:34am UTC](https://www.ruby-forum.com/t/re/207740/4 "2011-06-02T11:34:20Z")

</div>

Hello!

On Thu, Jun 02, 2011 at 09:33:49AM +0700, Edho P Arief wrote:

> - linux’s behavior caused binding to ::1 also binds to 127.0.0.1
> - nginx bind to 127.0.0.1
> - already bind from previous ::1, reporting error

No.

Maxim D.
