MacOS – Mac OS X Mavericks DNS name lookup order change

dnshostsmacosNetwork

I noticed Mavericks prefers the DNS server to /etc/hosts (scutil –dns). There used to be a good 'ol "order hosts,bind". Is there anything equivalent for Mavericks so my hosts file is consulted before reaching out to the DNS server? Thanks.

Best Answer

(Cross-posting my Reddit answer here.) In my experience, it's more of an additional priority issue: IPv6. It hit me in Mavericks, but probably dates back to Lion. I develop on my local machine using /etc/hosts aliases to route requests through nginx, but on slow Wifi with slow DNS, it will often hit a 5-second timeout before bailing out on IPv6 and trying IPv4, realizing that there's a relevant /etc/hosts entry, and resolving that way. Not very convenient to have +5s tacked onto my recode-reload cycle.

Adding a ::1 example.com line to go along with my 127.0.0.1 example.com lines resolved the issue for me.