You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行flutter doctor时HTTP主机可用性检测失败,求解决方案

Flutter Doctor HTTP主机无法访问的解决方案

1. 排查网络基础连接

  • 直接用浏览器访问cocoapods.org、maven.google.com、pub.dev、cloud.google.com,确认是否能正常打开。如果浏览器也无法访问,说明是网络本身的限制或故障。
  • 切换网络环境(比如从WiFi换手机热点),排除局域网层面的访问限制。

2. 重置DNS配置

手动更换为公共DNS地址,解决域名解析失败问题:

  • Windows:打开「网络和共享中心」→ 更改适配器设置 → 右键当前网络 → 属性 → 双击「Internet协议版本4(TCP/IPv4)」→ 选择「使用下面的DNS服务器地址」,填入114.114.114.114或8.8.8.8。
  • Mac:打开「系统设置」→ 网络 → 选中当前网络 → 高级 → DNS → 点击+号添加114.114.114.114或8.8.8.8。
  • Linux:编辑/etc/resolv.conf文件,添加nameserver 8.8.8.8,保存后执行sudo systemctl restart nscd重启网络服务。

3. 处理代理设置

  • 暂时关闭所有代理工具(系统代理、浏览器代理、第三方翻墙工具等),重新运行flutter doctor检测。
  • 若必须使用代理,需为Flutter配置代理环境变量:
    • Windows命令行:
      set HTTP_PROXY=http://代理地址:端口
      set HTTPS_PROXY=http://代理地址:端口
      
    • Mac/Linux终端:
      export HTTP_PROXY=http://代理地址:端口
      export HTTPS_PROXY=http://代理地址:端口
      
    配置完成后再执行flutter doctor。

4. 清理Flutter缓存

执行以下命令刷新依赖缓存:

flutter clean
flutter pub get

完成后再次运行flutter doctor。

5. 检查hosts文件映射

  • 打开hosts文件,确认目标域名没有被错误绑定:
    • Windows路径:C:\Windows\System32\drivers\etc\hosts
    • Mac/Linux路径:/etc/hosts
  • 删除所有涉及cocoapods.org、maven.google.com、pub.dev、cloud.google.com的错误条目,保存文件(需管理员权限)。
  • 刷新DNS缓存:
    • Windows:ipconfig /flushdns
    • Mac:sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    • Linux:sudo systemctl restart nscd

内容的提问来源于stack exchange,提问作者Trust shine

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 03:16:04