Difference between ping localhost and 127.0.0.1


Recommended Posts

Hey, does anyone could tell me the difference between ping localhost and ping 127.0.0.1?

I get different results from these two commands.

Link to comment
Share on other sites

localhost resolves to 127.0.0.1 on Windows. So you are bypassing the DNS subsystem when you ping the IP directly.

It may be different on Windows 7, where localhost resolves to an IPv6 address by default.

Link to comment
Share on other sites

Yes I'm trying on Win7 and i get ::1.

my further question is, why to resolve localhost to ipv6? what if i have Apache on my machine? it goes under ipv6?

Link to comment
Share on other sites

If your not using IPv6 -- you can just disable it.

reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 255

As you see my win 7 box does not resolve localhost to the ipv6 address

Microsoft Windows [Version 6.1.7600]

Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Windows\System32>ping localhost

Pinging quad-w7.local.lan [127.0.0.1] with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Link to comment
Share on other sites

If your not using IPv6 -- you can just disable it.

reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 255

As you see my win 7 box does not resolve localhost to the ipv6 address

Microsoft Windows [Version 6.1.7600]

Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Windows\System32>ping localhost

Pinging quad-w7.local.lan [127.0.0.1] with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Thanks BudMan~~ :shifty:

Link to comment
Share on other sites

Presumably this was done with the expectation that by the end of Windows 7s life cycle that IPv6 addresses will be the norm or even required.

Link to comment
Share on other sites

207624249.png

It's just the right thing to do if you have IPv6 enabled, it should try v6 first and fallback to v4 if it isn't possible.

Edit: It's so stuff like this works fine.

624247961.png

If you have v6 connectivity you should get the v6 address over the v4 one.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.