简体   繁体   English

本地主机正在工作,但 windows 7 中的 127.0.0.1 不工作

[英]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. 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.在我的 windows 主机文件中,我取消了 127.0.0.1 localhost 的注释,但问题仍然存在。 I have checked to see if firewall is blocking anything but still no good results.我检查了防火墙是否阻止了任何东西,但仍然没有好的结果。

How do I resolve this problem.我该如何解决这个问题。

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 . 您的Web浏览器可能会将计算机上的localhost解析为IPV6环回地址::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. 比较键入http://[::1]的结果,并将结果与http://127.0.0.1http://localhost进行比较,以查看是否显示任何内容。 As to why xampp is working on IPV6, but not IPV4 is another issue. 至于为什么xampp正在研究IPV6,而不是IPV4是另一个问题。

  • You might have a web proxy installed on your network and your Internet Options or browser settings is configured to use it. 可能在网络上安装了Web代理,并且您的Internet选项或浏览器设置已配置为使用它。 This will bypass DNS and the hosts file and send the request straight to the proxy. 这将绕过DNS和hosts文件,并将请求直接发送到代理。 And the proxy server probably resolves 127.0.0.1 and localhost differently. 并且代理服务器可能以不同方式解析127.0.0.1和localhost。 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. 这也适用于任何类型的本地代理,Internet加速软件,防病毒扫描程序,Fiddler等...尝试转到控制面板 - > Internet选项并选择连接选项卡。 Then select the "LAN settings" button. 然后选择“LAN设置”按钮。 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. 禁用Windows防火墙和/或您可能拥有的任何其他类型的防火墙软件。 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. 但您最好的选择是安装Wireshark或Netmon并获取http://localhost连接的跟踪,并将其与http://127.0.0.1地址进行比较。 That should reveal something... 这应该揭示一些......

netsh http add iplisten 127.0.0.1

这应该做的工作

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 open Turn Windows features on or off 2)转到windows searchcontrol 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.1 or http://localhost and get the correct page which should look like this image 4)现在我可以输入127.0.0.1http:// localhost并获取正确的页面,该页面看起来应该像这个图像

5) Profit . 5) Profit

I personally couldn't get 127.0.0.1 working on it's own in the Apache httpd.conf file. 我个人无法在Apache httpd.conf文件中使用127.0.0.1 So I added a port number at the end. 所以我在最后添加了一个端口号。 Usually it's just :80 . 通常它只是: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 localhost to find your apache server or your local ip address. 您可以键入localhost来查找Apache服务器或本地IP地址。 You can find your local ip address in cmd with an ipconfig command. 您可以使用ipconfig命令在cmd中找到本地IP地址。

If localhost working and 127.0.0.1 not working 如果localhost工作且127.0.0.1无法正常工作

Try 192.168.1.1 or 192.168.1.(your system number) 试试192.168.1.1192.168.1。(您的系统号)

It should work.. 它应该工作..

Here is a simple solution taken from here这是从此处获取的简单解决方案

Increase the priority of IPv4增加 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

Here is the result:结果如下:

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>

Hope this will help someone coming to this thread by 2022:)希望这将有助于到 2022 年来此主题的人:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 127.0.0.1 可访问/工作但本地主机不可访问/不工作 - 127.0.0.1 is accessible/working but localhost not accessible/ not working 本地主机、127.0.0.1 和主机文件在特定端口上不工作 - localhost, 127.0.0.1 and hosts file are not working on a specific port 如何从 Ubuntu 生产服务器访问 Windows 机器上的 localhost 或 127.0.0.1? - How to access localhost or 127.0.0.1 on a Windows machine from Ubuntu Production Server? “localhost”与“127.0.0.1”的表现 - “localhost” vs “127.0.0.1” performance Docker localhost进程无法在Windows上运行 - Docker localhost process not working on Windows 无法通过HttpClient连接到UWP中的127.0.0.1(localhost)设备门户(仅限Windows 10 Mobile RS1) - Can't connect to 127.0.0.1 (localhost) Device Portal in UWP by HttpClient or else (Windows 10 Mobile RS1 only) 如何将本地主机重定向到 127.0.0.1:8080? - How to redirect localhost to 127.0.0.1:8080? 在 windows 上将 192.168.0.10 映射到 127.0.0.1 - Map 192.168.0.10 to 127.0.0.1 on windows Windows身份验证可在localhost上运行,但不能在IIS的其他站点上运行 - Windows Authentication working on localhost but not on other site on IIS 环回127.0.0.1在Win 7中不起作用 - Loopback 127.0.0.1 not working in win 7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM