Lion takes long to connect to local server

Does your /etc/hosts file look like this?

[code lang=”bash”] gladlycode.local gladlycast.local babyessentials.local localhost[/code]

Every request I made to gladlyCode.local takes 5 seconds to resolve to my local Apache server. Something was wrong!

If it does and you’re on Mac OS X Lion, you should change your VirtualHost names to something else. It turns out that Mac OS X Lion no longer looks up /etc/hosts first when you try to lookup a .local domain since are technically reserved for Multicast DNS (MDNS), or Bonjour. Starting Lion, it will lookup through MDNS first, and after the 5 second timeout, it checks with /etc/hosts.

This is at a cost of developer productivity and I have to change all my .local domains to which is a domain name I own. I figured that if it is a domain name I own, it will never clash unknowingly. I changed ‘gladlycode.local’ into ‘’ and point it to now. Now testing gladlyCode no longer takes 5 seconds per request (ridiculous!).

Alternatively you can use another top level domain (TLD) instead of .local and the common ones such as .com.