Mental Jetsam

By Peter Finch

Browser slow to connect to localhost on Vista

Posted by pcfinch on July 11, 2008

I’m developing a little HTTP server in C++ on vista (don’t ask why). Anyway, I found that my browser was REALLY slow when trying to connect to the localhost server “http://localhost:8282/” but not the local IP address “http://127.0.0.1:8282/”. When I say slow, I mean about 1 second per connection. A bit of hunting around and I found the following lines in the \windows\system32\drivers\etc\hosts file.

127.0.0.1       localhost
::1             localhost

I didn’t recognize the last line or know what it does… so I commented it out (I live life on the edge some time!!). Anyway, things sped up! e.g.

127.0.0.1       localhost
# ::1             localhost

You’ll have to edit the hosts file as the administrator as it’s protected, but this simple little fixed work for me. If your having a similar problem, I hope this helps you too.

Advertisements

5 Responses to “Browser slow to connect to localhost on Vista”

  1. Stacy said

    I did that and my connection is still extremely slow. It takes about 30 seconds to load a page. Any other ideas?

  2. pcfinch said

    I’m not sure, but here is what I checked.

    1. Try accessing your server form “127.0.0.1″ (in the url e.g. “http://127.0.0.1/” ) or from another machine. If that is slow then it might have something to do with the configuration of your HTTP server.
    2. Check the proxy settings on your browser and make sure “localhost” and your machine name is in the ignore list or that “Bypass proxy for local addresses” is checked.
    3. Try doing a “tracert yourmachinename” from the command prompt. That will tell you if you TCP/IP traffic is being routed through some “odd” destination.
    4. Try using “telnet localhost 80” and see if that is slow. From a command prompt type “telnet localhost 80” and it should connect quickly to your server (if it’s running on port 80). Then type “GET / HTTP/1.0” and hit enter twice. You might not see what you type but you should get back a response back pretty quick. If not, then it might be your HTTP server again.
    5. As a last resort, be carefull here… try disabling IPV6 for your local network interface. “Control Panel->Network” then right click on “view status” for your local area connection then click properties, in the dialog interface, and disable IPV6 (not IPV4!!!!)… I assume you not using IPV6.

    I hope this helps.

  3. J said

    Maybe this article will help. It’s says ffox on Vista has issues with ip v6. http://weblogs.asp.net/dwahlin/archive/2007/06/17/fixing-firefox-slowness-with-localhost-on-vista.aspx

  4. Foup said

    Thank you for this hint, it worked perfectly for me !

  5. Rob Orland said

    I also had this exact same problem recently – ‘localhost’ taking 15 seconds to load, but 127.0.0.1 loading instantly.

    However, I have now fully solved my problem, so I write here in the hope that it will help someone.

    My problem coincided with the purchase of a D-Link DIR-655 wireless router, so after trying many of the kindly offered ‘fixes’ on this forum, I turned back to my router settings in search of an answer.

    I eventually discovered a setting on the SETUP – NETWORK SETTINGS page. The ‘Enable DNS Relay’ box was checked, so I read about it, and it apparently allows the router to lookup DNS addresses from the ISP’s server. This is obviously not desired for a ‘local’ address on my own PC, and so I tried unticking it…. and HEY PRESTO, IT WORKED!!!

    I hope this work for some of you, too!

    All the best,

    Rob

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: