本地主机正在工作,但在 Windows 7 中不是 127.0.0.1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25652409/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
localhost is working but not 127.0.0.1 in windows 7
提问by assetCorp
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.
我在 Windows 7 上运行 xampp。当我运行时http://localhost
,我在我的 Web 浏览器中看到了 xampp 欢迎屏幕,但http://127.0.0.1
不起作用。在我的 windows 主机文件中,我取消了 127.0.0.1 localhost 的注释,但问题仍然存在。我已经检查过防火墙是否阻止了任何东西,但仍然没有好的结果。
How do I resolve this problem.
我该如何解决这个问题。
回答by selbie
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 typinghttp://[::1]
and compare the results tohttp://127.0.0.1
andhttp://localhost
to see if that reveals anything. As to why xampp is working on IPV6, but not IPV4 is another issue.You mighthave 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 thehttp://127.0.0.1
address. That should reveal something...
您的 Web 浏览器可能正在
localhost
您的计算机上解析IPV6 环回地址::1
。比较打字http://[::1]
的结果并将结果http://127.0.0.1
与和 比较http://localhost
,看看是否揭示了任何东西。至于为什么 xampp 在 IPV6 上工作,而不在 IPV4 上是另一个问题。您的网络上可能安装了 Web 代理,并且您的 Internet 选项或浏览器设置已配置为使用它。这将绕过 DNS 和主机文件并将请求直接发送到代理。并且代理服务器可能以不同的方式解析 127.0.0.1 和 localhost。这也适用于任何类型的本地代理、互联网加速软件、防病毒扫描程序、Fiddler 等...尝试转到控制面板-> Internet 选项并选择连接选项卡。然后选择“LAN 设置”按钮。确保此对话框中的所有复选框均已关闭。运行“连接”对话框顶部的“设置”按钮只是为了确定。 见下图
禁用 Windows 防火墙和/或您可能拥有的任何其他类型的防火墙软件。这样我们就可以排除这种情况。任何改变?
但是您最好的选择是安装 Wireshark 或 Netmon 并获取
http://localhost
连接跟踪并将其与http://127.0.0.1
地址进行比较。那应该揭示一些东西......
回答by Lanayx
netsh http add iplisten 127.0.0.1
This should do the work
这应该做的工作
回答by josh.thomson
I personally couldn't get 127.0.0.1working on it's own in the Apache httpd.conffile. So I added a port number at the end. Usually it's just :80.
我个人无法在 Apache httpd.conf文件中单独运行127.0.0.1。所以我在最后添加了一个端口号。通常它只是:80。
However, I have Skype running on my machine which causes a conflict so I use port :8080.
但是,我的机器上运行 Skype 这会导致冲突,所以我使用端口:8080。
Listen 127.0.0.1:8080
听 127.0.0.1:8080
Is what I have in the config file and in the browser I enter: http://localhost:8080
是我在配置文件和浏览器中输入的内容: http://localhost:8080
This works and keeps it on local only. You can either type in localhostto find your apache server or your local ip address. You can find your local ip address in cmd with an ipconfigcommand.
这有效并仅将其保留在本地。您可以输入localhost来查找您的 apache 服务器或您的本地 IP 地址。您可以使用ipconfig命令在 cmd 中找到您的本地 IP 地址。
回答by maudulus
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.
1) 确保我将所有文件都C:\inetpub\wwwroot
备份到了某个地方,以防万一。
2) Go to the windows search
OR control panel
and openTurn Windows features on or off
2) 前往windows search
手术室control panel
并打开Turn 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).
3)Internet Information Services
需要勾选旁边的框(它将显示为灰色方块内的绿色方块)。
4) Now I can type 127.0.0.1or http://localhostand get the correct page which should look like this image
4) 现在我可以输入127.0.0.1或http://localhost并获得正确的页面,它应该看起来像这个图像
5) Profit
.
5)Profit
。
回答by Harikaran K
If localhostworking and 127.0.0.1not working
如果本地主机工作而127.0.0.1不工作
Try 192.168.1.1or 192.168.1.(your system number)
试试192.168.1.1或 192.168.1.(你的系统号)
It should work..
它应该工作..