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

解决Flutter HTTP主机可用性问题及项目运行连接重置异常

Flutter 在 Ubuntu 22.04 下的连接异常与 HTTP Host 检查超时问题

问题描述

  • 迁移至 Ubuntu 22.04 系统,已成功安装 Flutter(Channel main,3.4.0-19.0.pre.295)与 Android Studio(2021.2)
  • 运行项目时抛出异常:

Exception in thread "main" java.net.SocketException: Connection reset

  • 执行 flutter doctor 时,HTTP Host Availability 检查超时崩溃,日志如下:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel main, 3.4.0-19.0.pre.295, on Ubuntu 22.04.1 LTS 5.15.0-47-generic, locale en_US.UTF-8)
Checking Android licenses is taking an unexpectedly long time...
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] VS Code
[✓] Connected device (3 available)
HTTP Host availability check is taking a long time...
[☠] HTTP Host Availability (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at
      https://github.com/flutter/flutter/issues.
    ✗ Exception: HTTP Host Availability exceeded maximum allowed duration of 0:04:30.000000

! Doctor found issues in 1 category.

注:执行 flutter doctor 时已连接互联网

解决方法

  • 检查网络代理设置
    关闭系统全局代理,或执行以下命令清除 Flutter 代理配置:
    flutter config --no-proxy
    
  • 验证关键域名连通性
    测试 Flutter 依赖域名的连通性:
    ping storage.googleapis.com
    ping dl.google.com
    
    若无法连通,切换公共 DNS(如 8.8.8.8):
    sudo nano /etc/resolv.conf
    # 修改或添加:nameserver 8.8.8.8
    
  • 延长 Flutter Doctor 超时时间
    通过环境变量调整超时限制:
    export FLUTTER_DOCTOR_HTTP_TIMEOUT=300
    flutter doctor
    
  • 重置 Flutter 环境
    清理缓存并重新获取依赖:
    flutter clean
    flutter pub get
    
    手动运行 Android 许可证检查:
    flutter doctor --android-licenses
    
  • 切换至 Flutter 稳定通道
    当前使用的 main 通道为开发版,存在不稳定因素,切换至稳定通道:
    flutter channel stable
    flutter upgrade
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 11:55:25