Welcome! Log In Create A New Profile

Advanced

Re: NGINX not binding to localhost:80 only 127.0.0.1:80

Maxim Dounin
December 21, 2012 06:28AM
Hello!

On Thu, Dec 20, 2012 at 05:07:26PM -0800, Bill Culp wrote:

> Maxim,
>
> I used the
>
> listen localhost:80;
> listen [::]:80;
>
> And now the server responds to localhost.
>
> Not sure why this would be happening unless nginx was binding to v6 rather than v4
> either way its nice to have that annoyance gone.

The problem is not that nginx binded to ipv6 - it instead binded
to ipv4 only. But the tool you've used to connect to nginx only
used ipv6 (or used ipv6 as first option, and didn't fallback to
other addresses).

>
> Thanks!
> On Dec 20, 2012, at 2:27 PM, Maxim Dounin <mdounin@mdounin.ru> wrote:
>
> > Hello!
> >
> > On Thu, Dec 20, 2012 at 12:41:26PM -0800, Bill Culp wrote:
> >
> >> Ive had this issue with tomcat apache in the past and always
> >> fixed it by specifying localhost as part of the listen directive
> >> - not working with NGINX on OS X.
> >>
> >> NGINX is responding to 127.0.0.1 - but localhost it just drops
> >> the connection (its not refusing the connection, just dropping
> >> it)…
> >>
> >> Is there a way to fix this I have tried listen *:80, listen
> >> localhost:80 and still I cant reach it through the browser
> >> using localhost.
> >>
> >> localhost is resolvable with ping and has its entry in the hosts
> >> file.
> >
> > As of now
> >
> > listen localhost:80;
> >
> > will only listen on first ipv4 address resolved from the localhost
> > name. If you want nginx to listen on all ip addresses (likely
> > ipv4 127.0.0.1 and ipv6 ::1 in your case), you have to list them
> > explicitly, like this:
> >
> > listen 127.0.0.1:80;
> > listen [::1]:80;
> >
> > Or listen on both ipv4 and ipv6 wildcard addresses, like this:
> >
> > listen *:80;
> > listen [::]:80;
> >
> > Note well that to work with ipv6 addresses you need nginx compiled
> > with ipv6 support.
> >
> > --
> > Maxim Dounin
> > http://nginx.com/support.html
> >
> > _______________________________________________
> > nginx mailing list
> > nginx@nginx.org
> > http://mailman.nginx.org/mailman/listinfo/nginx
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

--
Maxim Dounin
http://nginx.com/support.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

NGINX not binding to localhost:80 only 127.0.0.1:80

Bill Culp December 20, 2012 03:42PM

Re: NGINX not binding to localhost:80 only 127.0.0.1:80

Jonathan Matthews December 20, 2012 04:12PM

Re: NGINX not binding to localhost:80 only 127.0.0.1:80

Bill Culp December 20, 2012 04:16PM

Re: NGINX not binding to localhost:80 only 127.0.0.1:80

Maxim Dounin December 20, 2012 05:28PM

Re: NGINX not binding to localhost:80 only 127.0.0.1:80

Bill Culp December 20, 2012 08:08PM

Re: NGINX not binding to localhost:80 only 127.0.0.1:80

Maxim Dounin December 21, 2012 06:28AM

Re: NGINX not binding to localhost:80 only 127.0.0.1:80

Bill Culp December 21, 2012 11:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 305
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready