http://localhost not working
Solution 1
The reason a ping responds with that address but browsing fails is because ping is using IPv6 automatically, and the system is resolving localhost with the IPv6 address, which your webserver apparently isn't serving on. If you add an entry to the Windows\System32\drivers\etc\hosts file with this:
127.0.0.1 localhost
then it should force the system to resolve localhost as the IPv4 address instead.
Another "fix" includes disabling IPv6, as Tie-fighter suggests, but really the "best" solution would be to make your webserver work when using IPv6 ("best" being a very subjective thing in this case).
Good luck,
--jed
Solution 2
Is there a weird VirtualServer for localhost that's different from the default one configured? When you use "localhost", it can get matched by a ServerAlias or ServerName configuration. If that configuration is bad, (eg: wrong wwwroot), then it won't work with the localhost, but might with an IP.
So check your httpd.conf for localhost
. Or add ServerAlias localhost
to the VirtualServer that's working properly.
--Christopher Karel
Solution 3
::1
is the IPv6 version of localhost, so it is working.
Localhost always translates to the loopback IP address
127.0.0.1
in IPv4, or::1
in IPv6.
Related videos on Youtube
kapitanluffy
Updated on September 17, 2022Comments
-
kapitanluffy over 1 year
i am using xampp 1.7.1 PHP 5.2.9
pinged localhost on cmd and it showed
Reply from ::1: time<1ms Reply from ::1: time<1ms Reply from ::1: time<1ms Reply from ::1: time<1ms
hosts file has
127.0.0.1 localhost 127.0.0.1 localhost.com 127.0.0.1 www.localhost.com
any other ideas? http://127.0.0.1 and http://ipaddress works
-
Anna Reed over 13 yearsPlease do elaborate what your problem is/what you are trying to do.
-
Admin over 13 yearsWhat is it you are trying to accomplish?
-
mmattax over 13 yearsThe obvious question: Are you sure that Apache is running?
-
kapitanluffy over 13 years@Jim mm..trying to browse localhost on a browser?
-
bitmask over 13 yearsDoes the error log (of the apache) show anything if you access
http://localhost
? -
kapitanluffy over 13 years@bit nothing actually i viewed the error.log file and these are the last 5 ones i saw [Sun Aug 15 18:30:17 2010] [notice] Digest: generating secret for digest authentication ... [Sun Aug 15 18:30:17 2010] [notice] Digest: done [Sun Aug 15 18:30:19 2010] [notice] Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9 configured -- resuming normal operations [Sun Aug 15 18:30:19 2010] [notice] Server built: Dec 10 2008 00:10:06 [Sun Aug 15 18:30:19 2010] [notice] Parent: Created child process 2652
-
kapitanluffy over 13 yearsi just uninstalled ipv6 from my computer. i will try what lain said..although i am sure i already did this.but he said that it works on him so ill try it again HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tcpip6\Parameters\DisabledComponents DWORD value 0x20 thanks for everyones help :)
-
-
Admin over 13 yearsIf the downvoter would like to leave a reason as to why this is not useful, I'll be happy to change it.
-
kapitanluffy over 13 yearsi think because most people around here knows that? xD well its still a bad idea to down vote someone xD
-
user9517 over 13 yearsIt's probably not getting anywhere near the router, he's using the loopback interface.
-
kapitanluffy over 13 yearsi ticked Microsoft TCP/IP Version 6 in the Network Connections>Local Area Connection>Properties..the ping still looks the same
-
tatan restrepo over 13 yearsi have a world of warcraft server and i had that issue, enter on this webpage canyouseeme.org and try with the diferent ports
-
kapitanluffy over 13 yearsactually there's no ::1 localhost..what i stated above are everything i have on the hosts file
-
kapitanluffy over 13 yearsso it means my apache doesnt support ipv6? so maybe ill go for disablibg the ipv6..how can i do that?like what i commented on tie fighter..i ticked TCP/IP version 6 in the properties of my Local Area Connection ..nothing happened..i guess im in the wrong way xD
-
user9517 over 13 yearsI updated my answer to reflect reality. I did this and my system now resolves localhost to 127.0.0.1 and not ::1
-
YwH over 13 yearsI haven't done much apache configuration lately, so the following is mere speculation, but I'd guess that it probably does support IPv6, it likely just needs to be enabled. You could see if anything is currently listening on port 80 for IPv6 by doing a "netstat -an" from the command line and looking for an entry similar to this one: "TCP [::]:80 [::]:0 LISTENING".
-
bitmask over 13 yearsI think that does not answer the question, because the problem is not in the result of the ping, but probably that entering
http://localhost
in the browser does not get one the same page ashttp://127.0.0.1
. However, this is pure speculation as the OP did not state the actual problem. -
kapitanluffy over 13 yearsi edited it with the value 20..the value shown is..0x0000020 it doesn't do anything..i don't know the exact value of 0x20..ill try inputting 20000000
-
kapitanluffy over 13 yearsmy problem is..when i tried browsing the localhost on my browser it says connection was reset. i tried 127 and it works..also for my ip
-
kapitanluffy over 13 yearsthe service listening on port 80 is apache it self..like i said..127 and my ip works..but not for localhost
-
kapitanluffy over 13 yearsuhm where exactly should i add that? sorry for being so noobish here xD
-
kapitanluffy over 13 yearsi have three actually.. TCP [::]:135 [::]:0 LISTENING 0 TCP [::]:8080 [::]:0 LISTENING 0 TCP [::1]:30606 [::]:0 LISTENING 0 ..so how can i enable ipv6?
-
Admin over 13 yearsI'm with Iain on this. 127 is loopback and it won't leave the machine.
-
r00tcreat0r over 13 yearsDWORD is a hex value, so 20 was correct. 20000000 won't help at all.
-
user9517 over 13 years@kapitanlufy: 0x20 is common notation for a
hexadecimal
value. After you have created the key double click on it and you'll get a pop up to edit the DWORD (32 bit) value. Ensure that theHexadecimal
radio button is checked and enter20
in the value data: box. Click OK.