5
2
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
127.0.0.1 test.local
and then perform the same cURL request:
curl -I http://test.local:3002/images/logo.png
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 test.local
delays.
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?
You should add that if you add the IP6 line to
hosts
(::1 test.local
), it will fix the issue. – Matt Alexander – 2014-04-23T19:51:36.487