Quick rules
- Emulator to local service: Use
10.0.2.2(Android Studio) or10.0.3.2(Genymotion) - Physical phone to local service: Use the PC’s real LAN IP, for example
10.0.1.54 - Never from a phone: Do not use
localhostor virtual adapter IPs like172.22.x.x - Gateway URL for phone: Use
ws://<LAN_IP>:8765 - Gateway binding: The gateway must listen on
0.0.0.0:8765or on the LAN IP — not only127.0.0.1:8765
Running the Flutter app on a physical Android device without USB
Use ADB wireless debugging.Phone setup
- Enable Developer options.
- Open Developer options.
- Turn on Wireless debugging.
- Open Wireless debugging and choose Pair device with pairing code.
- Keep that screen open so the phone shows the IP, pairing port, and pairing code.
PC setup
Run:adb devices, run the app:
If wireless pairing does not work
- Make sure the phone and PC are on the same Wi-Fi network.
- Re-run
adb connect. - Accept any RSA or debug prompt on the phone.
- Restart ADB:
Android 10 or older
Fully cable-free first-time pairing is usually not supported. A USB setup step may be required first.Running on the Android emulator
If the app is running on the Android emulator, ADB pairing is usually not needed. The emulator is already available to Flutter. Use:Emulator host IP rule
If the app must access a backend or service running on the same PC:- Android Studio emulator: use
10.0.2.2 - Genymotion: use
10.0.3.2
Finding the correct PC IP for a physical phone
To see the machine’s IPv4 addresses:How to choose the correct IP
Use the IPv4 address from the active LAN adapter that your phone can reach. Example from a typical setup:10.0.1.54is a correct machine IP for phone access (LAN adapter with a real default gateway).172.22.192.1is a Hyper-V virtual switch adapter and should not be used for the phone.
Rule of thumb
- Prefer the adapter with a real default gateway.
- Ignore loopback
127.0.0.1. - Ignore virtual adapters unless that network is intentionally being used.
Verifying whether port 8765 is listening
Check whether anything is listening on port8765:
Healthy result for phone access
You want to see one of these:0.0.0.0:8765<LAN_IP>:8765
Bad result
If you only see:127.0.0.1:8765::1:8765
Testing local reachability from the PC
Test whether the PC can reach its own service on the LAN IP:Interpretation
TcpTestSucceeded : Truemeans the service is reachable at that address and port from the PC.TcpTestSucceeded : Falsemeans either:- the app is not listening correctly
- the port is blocked
- the service is bound only to localhost
Hiro League Gateway bind troubleshooting
The most common failure is thathirogateway is configured to bind to localhost:8765.
That allows desktop local access but blocks phones.
Symptom
netstat shows:
Correct state
After fixing the bind host,netstat shows:
How to inspect current gateway instances
From the gateway package directory:How to fix the gateway host
Stop the gateway if needed:0.0.0.0:
Important file
The gateway instance registry lives at:host should be 0.0.0.0 for phone access.
Checking hirocli workspace defaults
For a local setup, no changes are needed.hirocli runs on the same machine as the gateway, so its default workspace config can still use:
Practical rule
- Desktop
hirocli:ws://localhost:8765 - Physical phone app:
ws://<LAN_IP>:8765
hirocli workspace gateway_url if the gateway is moved to a different machine.
Windows firewall
If the gateway is bound correctly but the phone still cannot connect, Windows firewall may be blocking the port.Test from the PC
Add a firewall rule
Run PowerShell as Administrator and allow inbound TCP on8765:
If the firewall command says access denied
PowerShell was not running as Administrator.Checking whether the phone is on a reachable network
The phone must be on a network that can route to the PC.What to verify on the phone
Open Wi-Fi settings and inspect the connected network:- Confirm the phone is on Wi-Fi, not mobile data.
- Confirm it is not on a guest network.
- Confirm VPN is off during debugging.
- Confirm there is no AP isolation or client isolation.
Compare IP ranges
Example addresses from a working setup:- PC IP:
10.0.1.54 - Phone IP:
10.0.6.98
10.x.x.x private space. They may not be on the same exact subnet, but if they can route through the same gateway, the connection will work. Router behavior matters.
If the phone reports “failed to open websocket connection”
That usually means:- the phone can reach the target IP enough to try opening a socket
- but the connection is being blocked, refused, or rejected before the WebSocket session is established
- gateway bind host
- firewall
- Android cleartext policy
- router isolation
Android app policy: cleartext traffic (ws://)
Android may block insecure cleartext traffic unless the app manifest allows it.
This matters when using:
wss://.
Required manifest settings
The app manifest must include:android:usesCleartextTraffic="true"android.permission.INTERNET
device_apps/android/app/src/main/AndroidManifest.xml
Current required shape
After changing the manifest
Rebuild the app:Correct URLs to use
Use the right URL depending on the environment.Physical phone to local gateway
Android emulator to local gateway
Desktop local process to local gateway
Do not use
ws://localhost:8765from the phonews://172.22.192.1:8765from the phone (unless intentional)
Full troubleshooting workflow
Use this sequence whenever device connection fails.- Confirm the app is using the correct URL for the environment.
- If using an emulator, use
10.0.2.2. - If using a phone, find the correct PC LAN IP with
ipconfig. - Verify the service is listening with:
- If you only see
127.0.0.1:8765, fix the gateway bind host to0.0.0.0. - Confirm local reachability from the PC:
- If needed, add a Windows firewall rule.
- Verify the phone is on Wi-Fi, not guest mode, and not using VPN.
- Ensure Android manifest allows cleartext traffic for
ws://. - Rebuild the app and test again.
- If it still fails, inspect Flutter logs and gateway logs during a connection attempt.
