I have a web server running on my local machine and when I perform a cURL request against it using the
localhost address it executes very fast. However, when I add an /etc/hosts like
and then perform the same cURL request:
it delays for a solid 2-3 seconds. Changing the cURL request back to
localhost again yields no delay.
This is reproducible every single time.
I've tried running the slow request under
dtruss to see if I can find a system call that is causing the delay. Nothing out of the ordinary shows up.
I've tried making a dummy service via
netcat that just returns
HTTP/1.0 200 OK so I can guarantee the issue is not really due to my web server. Again, no difference:
localhost is fast as you'd expect and
At this point I think there is somehow a DNS issue. That is,
/etc/hosts is NOT being consulted first, that is, my upstream DNS is being checked, which fails, then
/etc/hosts is being consulted which finally works.
Is this possible? Is
OS X Lion somehow consulting my
/etc/hosts later in the resolver chain?