Windows – Why is the localhost not but ::1, and what notation is that?


When I use the Ping command against my localhost (on Windows Vista), it doesn't show up as

C:\Windows\system32>ping localhost
Pinging GIGA [::1] from ::1 with 32 bytes of data:

ping pong

Instead, it shows up as ::1 (pair of colons and a one). What kind of notation is this? And why is it not showing up as

Here's what I see in the c:\windows\system32\drivers\etc\hosts file.

::1             localhost       localhost

As suggested by Gregg I have already tried changing this order.       localhost
::1             localhost

The expected result is that would take precedence over ::1 but that was not the case.

As I have learned now, this can be done by adding a prefix policy instead. To force cmd to use IP version 4 the option -4 can be used. To force Windows to always use IP version 4, IP version 6 or some of its components can be disabled through the properties dialog for the network adapter or through a registry tweak.

Best Answer

This is because ping on Windows Vista and newer Windows uses IPv6 by default when available. ::1 is a shortened notation of IPv6 loopback address - equivalent of IPv4 loopback

The full notation of the abbreviated ::1 IPv6 address is 0000:0000:0000:0000:0000:0000:0000:0001.

If you want to force ping to use IPv4 instead you can specify the IPv4 address explicitly or use the -4 option.

ping -4 localhost

If you want to change the IPv6/IPv4 preference overall you can check IPv4 vs IPv6 priority in Windows 7.

For additional information you can also see the article localhost.