Localhost not working but 127.0.0.1 does
This happens many times on windows, both XP and Vista when you are running a web server, say apache and are trying to access local websites using http://localhost, it don’t work and gives error as Connection TimeOut but if you access the site as http://127.0.0.1, it works.
I had faced similar problem with individual install of apache on my windows XP and with XAMPP on windows Vista too. It took me hours to find the actual problem. Here is what you want to do if you are not able to access local websites through http://localhsot but through http://127.0.0.1
Check your host file which contains all the mapping of IP and names. You can find your host file at /windows/sysetm32/etc folder. Open host file and see what it shows ?
Most likely it will be showing something like this
::1 localhost
in one line. Remove it and put this -
127.0.0.1 localhost
save the file and restart apache. This should solve the problem and now both localhost and 127.0.0.1 will be working. I am not sure why this happens but it looks host gets damaged due to force shutdown of the pc which results in corrupted Host file.
Related posts:
- Remove file type association with a program in Windows XP or Vista Many times this happens to us when a file gets...
- Apache Crashing due to Excessive Memory usage - Sites not loading Problem If your on a shared host or on VPS and...
- Firefox not Saving Cookies Firefox 3 often fails to save cookies which means every...
- Move Wordpress Blog from Subfolder to Root folder If you are looking to move your wordpress blog from...
- Create web based File Sharing site We all know and have used rapidshare and megaupload,...
1xz on Apr 23, 2009 :
Thank you very much for this post. I’ve been having the exact same problem with my xampp and your solution is spot on. With this approach i can even have add another alias for the localhost…cool!
Another thing to add, on Windows Vista, you have to open notepad through ‘run as administrator’ option first before opening the host file to be able to modify it.
Thanks again.
2Yoad on Apr 24, 2009 :
Just to make the picture a little brighter - the “::1″ entry in the hosts file is not an error or a corruption, but the equivalent of “127.0.0.1″ in IPV6.
So the OS with that entry defined the localhost IP address translation under the IPV6 network addresses scheme.
Thanks!
3vynxe on May 13, 2009 :
you could actually access it without running as administrator.
Just turn of the parental control in the control panel
Anyway, this is awesome! I have the same problem and it solved it!
Well done!
4gaurav on Dec 26, 2009 :
One Correction
in widows vista path would be
/windows/sysetm32/drivers/etc folder
instead of
/windows/sysetm32/etc folder