run flutter web with error, FormatException: Unexpected character (at character 1) <html>

Viewed 1010

I create a new Flutter project,and I run the commands

flutter channel beta
flutter upgrade
flutter config --enable-web

and this is my flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.17.0, on Mac OS X 10.15.2 19C57, locale zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.1)
[!] Proxy Configuration
! NO_PROXY is not set
[✓] Connected device (2 available)

! Doctor found issues in 1 category.

When I run flutter run -d Chrome --verbose , I get an error

Unable to connect to Chrome debug port: 51656
FormatException: Unexpected character (at character 1)
<html>
^

#0      throwToolExit (package:flutter_tools/src/base/common.dart:14:3)
#1      ChromeLauncher._connect (package:flutter_tools/src/web/chrome.dart:251:9)
<asynchronous suspension>
#2      ChromeLauncher.launch (package:flutter_tools/src/web/chrome.dart:183:12)
<asynchronous suspension>
#3      ChromeDevice.startApp (package:flutter_tools/src/web/web_device.dart:142:46)
#4      _ResidentWebRunner.run.<anonymous closure>                
(package:flutter_tools/src/build_runner/resident_web_runner.dart:443:29)
#5      _rootRunUnary (dart:async/zone.dart:1192:38)
#6      _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#7      _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#8      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#9      Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#10     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#11     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#12     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#13     _ResidentWebRunner._updateDevFS     (package:flutter_tools/src/build_runner/resident_web_runner.dart)
#14     _rootRunUnary (dart:async/zone.dart:1192:38)
#15     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#16     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#17     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#18     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#19     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#20     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:36:15)
#21     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:298:13)
#22     WebDevFS.update (package:flutter_tools/src/build_runner/devfs_web.dart)
#23     _rootRunUnary (dart:async/zone.dart:1192:38)
#24     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
#25     _FutureListener.handleValue (dart:async/future_impl.dart:141:18)
#26     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:682:45)
#27     Future._propagateToListeners (dart:async/future_impl.dart:711:32)
#28     Future._completeWithValue (dart:async/future_impl.dart:526:5)
#29     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:556:7)
#30     _rootRun (dart:async/zone.dart:1184:13)
#31     _CustomZone.run (dart:async/zone.dart:1077:19)
#32     _CustomZone.runGuarded (dart:async/zone.dart:979:7)
#33     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
#34     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#35     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#36     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#37     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)
3 Answers

Please try adding Chrome Dart Debug Extension in chrome and then try running command flutter run -d chrome.It should do the work. Also please check if something is blocking the chrome connection or try running with a different port or hostname.

for me I used proxy. so I set export http_proxy=; export https_proxy=; it works

Related