How can I make localhost resolve to 127.0.0.1 instead of ::1?
It depends on the application that you are using i.e. your application is asking for ipv6 address.
eg. telnet on linux tries to connect using ipv6 address before it tries, unless of course you specify protocol explicitly
default
x@x:~$ telnet localhost
Trying ::1...
Trying 127.0.0.1...
v4 specified
x@x:~$ telnet -4 localhost
Trying 127.0.0.1...
For your problem since you are not binding for v6 addresses (for apache and mysql services). In mysql and apache config you can explicitly specify "127.0.0.1" in places where localhost is specified. This should solve your problem.
Related videos on Youtube
JannieT
Updated on September 18, 2022Comments
-
JannieT almost 2 years
When I ping localhost the address resolves to the ipv6 loopback of ::1
My MySQL and Apache installations expects the ipv4 address of 127.0.0.1
How can I configure my WindowsXP to resolve localhost to 127.0.0.1?
My C:\WINDOWS\system32\drivers\etc\hosts file:
127.0.0.1 localhost 127.0.0.1 trunk 127.0.0.1 focus 127.0.0.1 demo
I have also have the following set in the Windows registry:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters] "DisabledComponents"=dword:00000255
Anything else I can try?
-
Admin over 12 yearsping -4 localhost
-
Paul over 12 yearsWho would upvote such a pointless comment. When you ping localhost and don't specify a protocol, it appears to be defaulting to ipv6. When apache and mysql lookup localhost, they will be specifying the protocol and so will get an ipv4 address if that is what is requested. Perhaps tell us a bit more about the problem you are seeing, as a different approach might be needed.
-
Ian Boyd over 11 yearsThis is similar to the bug in Visual Studio's built-in Cassini web-server: it refuses to listen on
::1
. As a result: it is, by default, unusable. Hopefully MySql is capable of binding to IPv6.
-
-
kinokijuf over 12 yearsYou should rather uninstall IPv6 altogether.
-
daya over 12 yearsNo, uninstalling IPv6 is not correct. Better solution is to change apache and mysql config to listen on IPv6 addresses as well
-
Tom over 12 years@daya Exactly. That's why I wrote the last sentence
-
JannieT over 12 years
-
daya over 12 yearsdo you have problem accessing mysql directly or through apache (eg php or cgi-bin)
-
JannieT over 12 yearsI can access MySQL via php, but not directly, see my new question:superuser.com/questions/377699/…