【问题标题】:curl: (7) Failed to connect to ::1: Network is unreachablecurl: (7) 连接失败 ::1: 网络不可达
【发布时间】:2012-06-22 15:12:18
【问题描述】:

当我在终端中输入 curl http://localhost:8000/ 以运行 python/tornado 脚本时,出现上述错误。

我的 curl 版本是 7.19.7。我禁用了 IPV6。

我的 /etc/hosts 读取

127.0.0.1   localhost
127.0.1.1   aniruddha-laptop

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

lsof | grep 8000的输出

dbus-daem  1338  aniruddha   67u     unix 0xf2208000      0t0       8923 socket
gconfd-2   1341  aniruddha   20u     unix 0xf2ab8000      0t0       7180 socket
trashappl  1468  aniruddha   18u     unix 0xf4248000      0t0       8689 socket
notificat  1478  aniruddha   14u     unix 0xf20a8000      0t0       8613 socket

【问题讨论】:

  • 您的/etc/hosts 文件中有什么内容?
  • 作为一个测试 - 如果你尝试 curl 127.0.0.1:8000 会发生什么?
  • @JonClements curl 127.0.0.1:8000 503 服务不可用

    503 服务不可用

    连接服务器失败127.0.0.1
  • @Aniruddha 如果你只是通过网络浏览器尝试,你会得到同样的结果吗? ::1 表示与 IPv6 有关,但 503 表示其他...
  • @BurhanKhalid '127.0.0.1 localhost 127.0.1.1 aniruddha-laptop # 以下行适用于支持 IPv6 的主机 ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00: :0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts'

标签: python curl tornado


【解决方案1】:

执行cat /etc/resolv.conf 你会找到nameserver 127.0.0.1,然后你应该移动这个条目并添加任何可用的名称服务器。

【讨论】:

  • "localhost" 在错误发生之前已经成功解析为::1。这不是 DNS 问题,除非 OP 在 /etc/hosts 中列出了 ::1,但也没有工作的 IPv6 堆栈——但 /etc/hosts 优先于外部 DNS 服务器,因此更改 resolv.conf 中的内容不会t 更改查找结果。
  • 此外,这个问题并不是“软件开发所独有的”,因为这里需要讨论主题,并且不应该回答离题的问题 - 请参阅回答好问的问题部分How to Answer.
猜你喜欢
  • 2011-10-13
  • 1970-01-01
  • 2013-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-27
相关资源
最近更新 更多