NGINX not binding to localhost:80 only 127.0.0.1:80

Maxim Dounin mdounin at mdounin.ru
Thu Dec 20 22:27:11 UTC 2012


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



More information about the nginx mailing list