dongzong8110 2018-05-14 15:24
浏览 1316

为什么无法使用任何端口连接到127.0.0.1上的http服务绑定

I wrote a simple http server in Go language as below:

http.ListenAndServe(":8888", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("hello"))
}))

When I test it on certain machine runs Windows 7, I found client can't connect to the server.

telnet 127.0.0.1 8888
connecting 127.0.0.1… can't open connection to the host.  on port 8888: connect failed. (I translate it from Chinese.)

Then I got the results of other test case:

  1. ping localhost and 127.0.0.1, successful.
  2. telnet localhost 8888, successful.
  3. telnet ::1 8888, successful.
  4. netstat -ano | find "8888", the server has listened 0.0.0.0:8888 and :::8888.
  5. Check the hosts file of OS, it's default configuration (nothing else).
  6. Check the Network Adapter, it doesn't open IPV6 adapter.
  7. The machine is in domain network.
  8. The IP Security Policy is an empty list.
  9. When I opened the MMC(Microsoft Management Console), I got a warning like this:
    message box
    It mean's:
    Can't find resource "$(string.SiteDiscoveryEnableWMI)" (references in property displayName)
. File C:\windows\PolicyDefinitions\inetres.admx, line 64620, row 235

Anyone can tell me what's going on?

  • 写回答

1条回答 默认 最新

  • dream2891 2018-05-14 15:29
    关注

    If XAMPP is running in your machine, the local server sometimes uses 127.0.0.1 as the default. This could be the reason that ping localhost is working but telnet is not.

    Otherwise check other network services or localservers you have running for any conflicts.

    Cheers!

    评论

报告相同问题?

悬赏问题

  • ¥15 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!