For the purposes of doing web development, I have several domain names specified in my
/etc/hosts. These represent several different websites that are being run locally.
127.0.0.1 site1.local 127.0.0.1 site2.local 127.0.0.1 site3.local
This works fine, but I'm seeing a 5 second delay in loading pages from any of these domains. Browser developer tools attribute this delay to DNS, and it's always exactly 5 seconds.
Curiously, this also only happens in Chrome and in Firefox. Safari has no delay at all.
I thought that perhaps the browser is querying the normal DNS servers before falling back to the hosts file. Doing a DNS query with
dig site1.local returns no results (as you would expect), but also returns results very quickly (17ms), so that doesn't seem to be the case.
What is causing the 5 second delay in looking up hosts in the
/etc/hosts file, and how do I reduce or eliminate this delay?