localhost is working but not 127.0.0.1 in windows

2019-07-04 00:39发布

问题:

I am running xampp on windows 7. When I do http://localhost, I get the xampp welcome screen in my web browser but http://127.0.0.1 does not work. In my windows hosts file, I have uncommented 127.0.0.1 localhost but the problem still exists. I have checked to see if firewall is blocking anything but still no good results.

How do I resolve this problem.

回答1:

Two or three shot in the dark guesses. This is how I would diagnose the issue.

  • It's possible that your web browser is resolving localhost on your computer to the IPV6 loopback address, ::1. Compare the results of typing http://[::1] and compare the results to http://127.0.0.1 and http://localhost to see if that reveals anything. As to why xampp is working on IPV6, but not IPV4 is another issue.

  • You might have a web proxy installed on your network and your Internet Options or browser settings is configured to use it. This will bypass DNS and the hosts file and send the request straight to the proxy. And the proxy server probably resolves 127.0.0.1 and localhost differently. This also applies to any sort of local proxy, internet speed-up software, anti-virus scanner, Fiddler, etc... Try going to Control Panel->Internet Options and select the Connections tab. Then select the "LAN settings" button. Make sure all the checkboxes are turned off on this dialog. Run the "Setup" button at the top of the Connections dialog just to be sure. See picture below

  • Disable the Windows Firewall and/or any other sort of Firewall software you may have. Just so we can rule that out. Any change?

  • But your BEST option will be to install Wireshark or Netmon and get a trace of http://localhost connection and compare that to the http://127.0.0.1 address. That should reveal something...



回答2:

netsh http add iplisten 127.0.0.1

This should do the work



回答3:

What I had to do was:

1) Make sure I had all files located inside of C:\inetpub\wwwroot backed up somewhere, just in case.

2) Go to the windows search OR control panel and openTurn Windows features on or off

3) The box next to Internet Information Services needs to be checked (it will appear as a green square inside of the grey square).

4) Now I can type 127.0.0.1 or http://localhost and get the correct page which should look like this image

5) Profit.



回答4:

I personally couldn't get 127.0.0.1 working on it's own in the Apache httpd.conf file. So I added a port number at the end. Usually it's just :80.

However, I have Skype running on my machine which causes a conflict so I use port :8080.

Listen 127.0.0.1:8080

Is what I have in the config file and in the browser I enter: http://localhost:8080

This works and keeps it on local only. You can either type in localhost to find your apache server or your local ip address. You can find your local ip address in cmd with an ipconfig command.



回答5:

If localhost working and 127.0.0.1 not working

Try 192.168.1.1 or 192.168.1.(your system number)

It should work..