I’m running some python code for the first time on a Windows 7 machine and noticed that this http request to my localserver is much slower than before:
result = urllib2.urlopen(“http://localhost:3000/somepath”).read()
This is called repeatedly and each time instead of returning immediately it takes around a second.
If I replace localhost with 127.0.0.1, it returns immediately as before (was on Mac OS).
No big deal but was curious as to the cause.
If it’s DNS, why is it not being cached?
Per yotam.shacham’s comment, this problem can be fixed by uncommenting this line from the Windows
hostsfile:On Windows 7, the `hosts file is located at
where
%SystemRoot%is normallyC:\WINDOWS