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

Flutter Web调试报错:无法连接Chrome调试端口求助

问题描述

运行空Flutter Web应用时执行命令:

flutter run -d chrome

出现如下错误:

Unable to connect to Chrome debug port: 50848
 SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 50849

已尝试切换Flutter渠道(stable、main)、重装Chrome,问题仍未解决。以下是Flutter doctor截取信息:

[✓] Flutter (Channel main, 3.21.0-9.0.pre.26, on macOS 12.7.2 21G1974 darwin-x64, locale en-MA)
    • Flutter version 3.21.0-9.0.pre.26 on channel main at /Users/xyz/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e7baebdce7 (2 hours ago), 2024-03-16 08:56:23 -0400
    • Engine revision e4602aa149
    • Dart version 3.4.0 (build 3.4.0-240.0.dev)
    • DevTools version 2.33.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

解决方法

  • 手动指定调试端口:避免端口占用冲突,执行命令:
    flutter run -d chrome --web-port=8080
    
  • 关闭防火墙/代理:macOS系统防火墙或第三方代理工具可能拦截本地连接,暂时关闭后重试。
  • 彻底重启Chrome:终端执行命令杀死所有Chrome进程,再重新启动浏览器:
    pkill -f "Google Chrome"
    
  • 清除Flutter缓存:清理项目构建缓存后重新构建:
    flutter clean
    flutter pub get
    
  • 检查localhost解析:终端执行ping localhost确认解析正常,若异常则修改/etc/hosts文件,确保存在127.0.0.1 localhost配置。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 21:07:05