Quick fix: the Flutter error "connecting to the service protocol: failed to connect" means the flutter tool could not reach your running app's Dart VM Service, the debug connection used for hot reload and DevTools. On an iPhone, the usual cause is a blocked Local Network permission: open Settings > Privacy & Security > Local Network and turn your app on, then run again. On any platform, if the app closes straight after launch, it crashed before Dart started. Run it from Xcode or watch adb logcat to see the real error (step 3).
Type "flutter error" into Google and the second suggestion is "flutter error connecting to the service protocol failed to connect to". The full message usually looks like this:
Error connecting to the service protocol: failed to connect to http://127.0.0.1:51062/xxxxxxxx=/ws
On iOS devices you may see a related message instead: Error: Did not find a Dart VM Service advertised for com.example.app. Both mean the same thing: the app was installed, but the Flutter tool never connected to it. This guide explains why the Flutter service protocol error happens and fixes it in order, quickest and safest first.
Why "error connecting to the service protocol" happens
When you run a debug build, the app starts a small server inside the Dart VM. The flutter tool finds that server and connects to it over a local port, which is why the message shows 127.0.0.1. The connection fails when:
- iOS blocks local network access. Since iOS 14, Flutter's documentation says you must accept a permission dialog before debugging features such as hot reload and DevTools work. If you tapped "Don't Allow", or the dialog never appeared, the tool cannot find the app.
- The app crashed at startup. A native crash, for example two plugins registering the same name, kills the app before Dart runs. The Flutter log then shows only the service protocol error, not the real crash.
- Stale build files after a Flutter upgrade, a plugin change or a switch of device.
- Something sits between the tool and the app: a VPN, a proxy that also catches
127.0.0.1, or another process already using the port. - The device connection itself is unhealthy, such as an unauthorized Android device or a confused
adbserver.
How to fix the Flutter service protocol error
Try these steps in order and run flutter run again after each one.
- Stop, uninstall the app and run again. Stop the debug session, delete the app from the phone, simulator or emulator, and run
flutter runagain. A fresh install also gives iOS a new chance to show the Local Network dialog. Watch the device and tap Allow when it appears. - On iPhone, allow Local Network access. Open Settings > Privacy & Security > Local Network and turn on your app. Flutter's iOS debugging page says this permission is needed for debug and profile builds only and does not appear in release builds. If you added Flutter to an existing iOS app (add-to-app), the Debug
Info.plistalso needs_dartVmService._tcpin its Bonjour Services array. The Flutter docs warn never to add this to your Release build. - Find out whether the app crashed. If the app opens and closes at once, look at the native log:
In Xcode choose Product > Run and read the console. One documented case showed# Android: watch the log while you run the app adb logcat '*:E' # iOS: open the native project and run it from Xcode open ios/Runner.xcworkspaceDuplicate plugin keybecause two packages registered the same iOS plugin. Removing one of them frompubspec.yamlfixed it. Fix whatever crash you find, then go back toflutter run. - Clean the build. Old build output often causes this error after an upgrade:
If your iOS project still uses CocoaPods, also runflutter clean flutter pub get flutter runcd ios && pod install && cd ..beforeflutter run. Since Flutter 3.44, the Flutter docs say iOS and macOS dependencies are managed with Swift Package Manager by default, with CocoaPods in maintenance mode. - Turn off VPNs and check proxy settings. Disconnect any VPN and try again. If you use a proxy, make sure
NO_PROXYincludeslocalhostand127.0.0.1, so local traffic is not sent through it:
Then run# macOS / Linux export NO_PROXY=localhost,127.0.0.1,::1 # Windows (PowerShell) $env:NO_PROXY="localhost,127.0.0.1,::1"flutter doctor -v. When a proxy is set, its Proxy Configuration section tells you ifNO_PROXYis missing a loopback address. - Free the port. If the error always shows the same port, another process may hold it. On macOS or Linux, find it and stop it (use your port number):
On Windows uselsof -nP -i4TCP:51062 kill <PID>netstat -ano | findstr 51062and end that process in Task Manager. Restarting the computer also clears stuck processes. - Reset the device connection. On Android, restart
adband check the device shows asdevice, notunauthorized:
If it saysadb kill-server adb start-server adb devicesunauthorized, unlock the phone and accept the USB debugging prompt. On iOS, restart the iPhone and reconnect it. Make sure it is unlocked and trusts the Mac. - Update Flutter and check your setup. Run
flutter upgrade, thenflutter doctor -v, and fix anything marked with a cross. Device and tool fixes ship in regular releases, so an old SDK can keep failing on a newer phone OS.
If nothing works
Run flutter run -v and read the lines just before the error. They show which device, port and discovery method the tool tried. For iPhones, some developers fixed it by deleting and recreating the Runner scheme in Xcode (Product > Scheme > Manage Schemes) after switching phones. That is a single report, so try it only after the steps above. Then search the Flutter issue tracker for your exact message and include your flutter doctor -v output if you open a new issue.
Other build errors? See our fixes for "Gradle task assembleDebug failed", "No target device found" and a missing Xcode simulator.
Frequently asked questions
What is the Dart VM Service in Flutter?
It is a debug server that runs inside your app in debug and profile mode. The flutter tool, your IDE and DevTools connect to it for hot reload, breakpoints and performance tools. Release builds do not include it.
Why does the error only happen on my iPhone?
iOS 14 and later ask for Local Network permission before the flutter tool can find the debug server. Turn the app on in Settings > Privacy & Security > Local Network, or reinstall the app and tap Allow.
Can I still use the app if this error appears?
Sometimes the app keeps running, but hot reload, logs and DevTools will not work because the tool never connected. If the app closed at once, it crashed and needs fixing first.
Does this error affect release builds?
No. The service protocol is only used by debug and profile builds. A release build on the App Store or Play Store does not try to connect to it.
Sources and further reading
- Flutter docs: iOS debugging (Local Network permission)
- Flutter docs: Integrate a Flutter app into your iOS project (Bonjour Services, Swift Package Manager)
- flutter_tools source: the flutter doctor proxy check for NO_PROXY
- Stack Overflow: Flutter iOS device "Error connecting to the service protocol" (user reports)
- DEV Community: a service protocol failure caused by a duplicate iOS plugin key
- DEV Community: "Did not find a Dart VM Service" fixed by recreating the Runner scheme
Last checked November 28, 2026 against the Flutter 3.50 documentation.