Sunday, January 16, 2011

What's the difference between running localhost and 127.0.0.1?

Hi

My windows 7 is messed up somehow and no one seems to know what is wrong. My localhost runs so slow it is not even funny. To run my website on local host takes like 20 seconds to load up.

I change it to 127.0.0.1 and it loads up in 1 second. So I am not sure what the difference is between them.

I am also unsure how to set 127.0.0.1 to load up instead of localhost when running my website through Visual Studio Web Developer Express 2008.

  • localhost is just a name mapped in your 'hosts' file. possibly located at:

    c:\windows\system32\drivers\etc\hosts
    

    I agree with aziz, that it's something underlying issue with DNS on your system.

    Richard : Note, in Windows 7 the "localhost" to IP address (v4 or v6) is done in the DNS client code *not* in the hosts file (the file contains a comment to this effect).
  • First of all 127.0.0.1 is a IPv4 address and localhost is a host name. Host names must be resolved to get IP addresses. They can be resloved by DNS and the hosts file at c:\windows\system32\drivers\etc\hosts.

    This is the entry of my hosts file:

    ::1 localhost

    But what is this: "::1"? An IPv6 address for the local computer. You can check your web app with this url against this IPv6 adress:

    http://[::1]/
    

    This request must do well. If not your web system has problems with IPv6 addresses. If this request is ok, you have an DNS issue.

  • You may improve speed by changing

     ::1 localhost
    

    to

     127.0.0.1 c:\windows\system32\drivers\etc\hosts
    

    As far as I know ::1 is device identifier, so it uses its IP address. Since loopback is almost fixed, you can safely change it.

    Terje Mikal : ::1 is the IPv6 version of 127.0.0.1

0 comments:

Post a Comment