![](/img/trans.png)
[英]127.0.0.1 is accessible/working but localhost not accessible/ not working
[英]localhost is working but not 127.0.0.1 in windows 7
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. 在我的 windows 主机文件中,我取消了 127.0.0.1 localhost 的注释,但问题仍然存在。 我检查了防火墙是否阻止了任何东西,但仍然没有好的结果。
我该如何解决这个问题。
在黑暗的猜测中拍摄了两三个镜头。 这就是我诊断问题的方法。
您的Web浏览器可能会将计算机上的localhost
解析为IPV6环回地址::1
。 比较键入http://[::1]
的结果,并将结果与http://127.0.0.1
和http://localhost
进行比较,以查看是否显示任何内容。 至于为什么xampp正在研究IPV6,而不是IPV4是另一个问题。
您可能在网络上安装了Web代理,并且您的Internet选项或浏览器设置已配置为使用它。 这将绕过DNS和hosts文件,并将请求直接发送到代理。 并且代理服务器可能以不同方式解析127.0.0.1和localhost。 这也适用于任何类型的本地代理,Internet加速软件,防病毒扫描程序,Fiddler等...尝试转到控制面板 - > Internet选项并选择连接选项卡。 然后选择“LAN设置”按钮。 确保在此对话框中关闭所有复选框。 运行“连接”对话框顶部的“设置”按钮以确定。 见下图
禁用Windows防火墙和/或您可能拥有的任何其他类型的防火墙软件。 这样我们就可以排除这一点。 任何改变?
但您最好的选择是安装Wireshark或Netmon并获取http://localhost
连接的跟踪,并将其与http://127.0.0.1
地址进行比较。 这应该揭示一些......
netsh http add iplisten 127.0.0.1
这应该做的工作
我必须做的是:
1)确保我在C:\\inetpub\\wwwroot
内部的所有文件备份到某处,以防万一。
2)转到windows search
或control panel
,打开Turn Windows features on or off
3)需要检查Internet Information Services
旁边的框(它将在灰色方块内显示为绿色方块)。
4)现在我可以输入127.0.0.1或http:// localhost并获取正确的页面,该页面看起来应该像这个图像
5) Profit
。
我个人无法在Apache httpd.conf文件中使用127.0.0.1 。 所以我在最后添加了一个端口号。 通常它只是:80 。
但是,我在我的机器上运行Skype会导致冲突,因此我使用端口:8080 。
听127.0.0.1:8080
我在配置文件和我输入的浏览器中有什么: http:// localhost:8080
这可以工作,只保留在本地。 您可以键入localhost来查找Apache服务器或本地IP地址。 您可以使用ipconfig命令在cmd中找到本地IP地址。
如果localhost工作且127.0.0.1无法正常工作
试试192.168.1.1或192.168.1。(您的系统号)
它应该工作..
这是从此处获取的简单解决方案
增加 IPv4 的优先级
Microsoft Windows [Version 10.0.19044.1826]
(c) Microsoft Corporation. All rights reserved.
C:\WINDOWS\system32>netsh interface ipv6 show prefixpolicies
Querying active state...
Precedence Label Prefix
---------- ----- --------------------------------
50 0 ::1/128
40 1 ::/0
35 4 ::ffff:0:0/96
30 2 2002::/16
5 5 2001::/32
3 13 fc00::/7
1 11 fec0::/10
1 12 3ffe::/16
1 3 ::/96
C:\WINDOWS\system32>
C:\WINDOWS\system32>netsh interface ipv6 set prefixpolicy ::ffff:0:0/96 55 4
Ok.
C:\WINDOWS\system32>
C:\WINDOWS\system32>netsh interface ipv6 show prefixpolicies
Querying active state...
Precedence Label Prefix
---------- ----- --------------------------------
55 4 ::ffff:0:0/96
50 0 ::1/128
40 1 ::/0
30 2 2002::/16
5 5 2001::/32
3 13 fc00::/7
1 11 fec0::/10
1 12 3ffe::/16
1 3 ::/96
结果如下:
C:\WINDOWS\system32>ping localhost
Pinging Sumonst21 [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Ping statistics for 127.0.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\WINDOWS\system32>
希望这将有助于到 2022 年来此主题的人:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.