gpt4 book ai didi

curl - curl无法连接到本地主机端口80

转载 作者:行者123 更新时间:2023-12-03 08:54:04 28 4
gpt4 key购买 nike

我的主机文件将127.0.0.1映射到localhost

$ curl -I 'localhost'
curl: (7) Failed to connect to localhost port 80: Connection refused

接着
$ curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.2.4
Date: Wed, 09 Apr 2014 04:20:47 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Oct 2012 21:48:34 GMT
Connection: keep-alive
Accept-Ranges: bytes

在我的主机文件中
127.0.0.1   localhost

看来 curl命令无法识别 /etc/hosts中的条目。有人可以解释为什么吗?

更新:我还没有尝试过,但是我发现您可以配置 nginx to respond to ipv4 and ipv6

最佳答案

由于您的主机文件中包含::1 localhost行,因此curl似乎正在尝试使用IPv6与本地Web服务器联系。

由于Web服务器未在IPv6上进行侦听,因此连接失败。

您可以尝试对--ipv4使用curl选项,这在两个选项均可用时应强制进行IPv4连接。

关于curl - curl无法连接到本地主机端口80,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22952676/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com