We tried installing a 3rd party software product on a new Windows Server 2008 R2 machine and found that everything works except for accessing local services through loopback addresses such as localhost
or the computer name (ex: VPS-Web
which resolves to localhost
). We are not using IPv6 and would like to disable it until the software is compatible.
I tried using these instructions for disabling IPv6 on Windows 2008 R2 but it did not disable the protocol for localhost
. Pinging localhost
or VPS-Web
will still return ::1:
instead of 127.0.0.1
. I can use ping localhost -4
to get the correct address, but IPv6 takes precedence over IPv4 so the 3rd party software only gets the IPv6 address.
I had initially checked the host file as SilverbackNet suggested, but on a Windows 2008 R2 server this is the default file:
#
indicates a comment in the host file, so all the entries are commented out, and the first line is a bit confusing. I then noticed that there were two entries for localhost that were commented out, so I tried uncommenting the IPv4 one and it worked! I should have tried that first but I was thrown off track by the first line. Using the below host file pinging the computer name or localhost will always return an IPv4 address, which fixes the problem with the 3rd party software!Setting "DisabledComponents" = 0x20 under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\
will set that machine to use IPv4 instead of IPv6 in prefix policies.
Create the registry key if it doesn't exist.
Have you tried removing the entry from the hosts file in %systemroot%\system32\drivers\etc? That should do it, if you just need "localhost" to always be IPv4. However, if it's based on the server name, this probably won't work.
The initial ServerFault thread about using the
DisabledComponents
registry value is really the best way to do this. Hosts file tweaking should never be necessary in a well functioning network. The registry tweak is also much easier to deploy and revert via group policy if you have an Active Directory.The reason it didn't work is because that
DisabledComponents
registry setting is read as a set of bit flags and not simply on or off. Here is the official documentation from Microsoft on the subject:How to disable IP version 6 (IPv6) or its specific components in Windows 7, in Windows Vista, in Windows Server 2008 R2, and in Windows Server 2008
The short version is that to completely disable IPv6 on Vista/2008 and beyond, set the value of
DisabledComponents
to0xff
. I do this on every machine I manage where we're not explicitly using IPv6. It has the nice side effect of significantly shortening the output of theipconfig
command.You can also go into the properties of the NIC itself, and uncheck the IPv6 box, leaving IPv4 enabled. Should do the trick.
Try adding a line to your hosts file like:
::1 VPW-Web
This should enable the resolver to get
VPW-Web
as a name for IPv6 loopback.