问题
I am using wamp for few years and i upgraded to windows 8 few months before, my wamp working smoothly up to yesterday. But now it can't be accessed using localhost. but when i trying 127.0.0.1 instead it works smoothly. I changed ::1 localhost to 127.0.0.1 localhost in host file. which where the solution suggested for this problem in most websites. But unfortunately its not work for me. When i ping localhost its showing replay from ::1: time<1ms. And There is no software's using port 80 i already checked it. please help to solve this.
回答1:
Edit
%SystemRoot%\system32\drivers\etc\hosts
and replace
::1 localhost
with
127.0.0.1 localhost
Save and restart apache. Hope it will work .
回答2:
Add 127.0.0.1 localhost
to your hosts file.
If there is a #
(comment sign) in front of it, remove it.
Remove other instances of localhost, or place a #
in front of those other instances.
Your hosts file is usually in c:\windows\system32\drivers\etc\hosts
, and when you try to edit this file run notepad (or any other preferred editor) as ADMINISTRATOR, otherwise chances are big your modifications wont be saved.
After doing all this, in your browser do a control-f5 (refresh without using the cache).
回答3:
For DNS problem:
ipconfig /flushdns
ipconfig /registerdns
or rather backup the code and reinstall the wamp server.
Much faster solution however remember you're wamp settings.
回答4:
After adding the line 127.0.0.1 localhost to the hosts file, copy the contents of hosts file and paste it in another new file, then replace the old hosts files with the new one. This worked for me.
回答5:
Resolved Issue by editing /etc/hosts file: I also had similar issue(Able to ping 127.0.0.1, but issue while pinging localhost). I resolved it by removing entries like ::1 localhost, ff81::1%lo0 localhost with only 127.0.0.1 localhost.... I removed rest of the entries for localhost. I done this for my mac.
After this process I can debug my java application using eclipse.
回答6:
You can remove comment (# row start) or add 127.0.0.1 localhost In your hosts (folder etc)
Open this file with privilege admin
回答7:
This issue also arises if you edited your vhosts.conf file and added a virtual host. To resolve comment out every line of the virtual host entry, e.g. If using xampp, edit your entry in vhosts.conf and comment all the lines (add an # before each line)
##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host.example.com
##DocumentRoot "E:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>
then un-comment or add 127.0.0.1 localhost
in your hosts file.
回答8:
I ran into the same problem with XAMPP on my Mac and (finally) figured out how to fix it. Something similar might work for you on Windows:
Even though my /etc/hosts file looked correct, I had a feeling it wasn't working. ("ping localhost" returned no results, but "ping 127.0.0.1" was working.) So, I found that there was a copy of the original hosts file (/etc/hosts~orig) which I replaced my current hosts file with. That did the trick after restarting Apache.
$ sudo mv /etc/hosts /etc/hosts~old
$ sudo cp /etc/hosts~orig /etc/hosts
$ ping localhost
来源:https://stackoverflow.com/questions/20345132/127-0-0-1-is-accessible-working-but-localhost-not-accessible-not-working