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 hosts
file:
127.0.0.1 localhost
On Windows 7, the `hosts file is located at
%SystemRoot%\system32\drivers\etc\hosts
where%SystemRoot%
is normally C:\WINDOWS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With