Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using Mac OS X 10.8.2 and I have in my local /etc/hosts this content:

127.0.0.1 dev.test.local

Together with that I locally got nginx installed to serve static files for that domain. And while it works it takes ~5 seconds before nginx gets the connection. Demonstrated by:

ba@djuproera% time curl -I http://dev.test.local/  
curl: (7) couldn't connect to host
curl -I http://dev.test.local/  0.00s user 0.00s system 0% cpu 5.010 total

What I noticed was that if I change my hosts file to this:

127.0.0.1 dev.test.com dev.test.local

I get normal sub-second responses:

ba@djuproera[master*](ruby-1.9.3)% time curl -I http://dev.test.local/
curl: (7) couldn't connect to host
curl -I http://dev.test.local/  0.00s user 0.00s system 2% cpu 0.285 total

Extra interesting is that if I switch the order of the domains in the hosts file I get slow responses again:

127.0.0.1 dev.test.local dev.test.com

Gives:

ba@djuproera[master*](ruby-1.9.3)% time curl -I http://dev.test.local/
curl: (7) couldn't connect to host
curl -I http://dev.test.local/  0.01s user 0.00s system 0% cpu 5.011 total

Do anyone have any idea what's going on here?

share|improve this question
    
And while curl is saying it can't connect that's just because I had disabled nginx to see if the problem was nginx or something else, as it turned out it was something else… –  gaqzi Jan 22 '13 at 16:42

1 Answer 1

up vote 1 down vote accepted

Seems the problem has to do with using .local:

All .local domains are technically reserved for Multicast DNS (Bonjour), 
and Lion no longer looks in /etc/hosts first when you try to lookup 
a .local domain. Instead, it asks MDNS first, waits out the 5 second 
timeout, then checks /etc/hosts.

Source: http://itand.me/mac-os-x-lion-local-domains-and-etchosts-oh-m

It's funny how defining two different domains make it work though, if the first host is made first with another TLD.

share|improve this answer
    
That link is now dead. Try this one instead: en.wikipedia.org/wiki/.local. –  DaveBurns Mar 5 at 21:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.