Skip to content

[Bug]: Android devices missing on WSL mirrored networking until an adb server is running #37867

Open

Description

@AadiJo

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server (local device host, expo-device-hub 0.22.1)

Steps to reproduce

  1. Run the T3 server in WSL2 with networkingMode=mirrored in .wslconfig.
  2. Install the Android SDK in WSL (emulator, platform-tools, cmdline-tools) and create an AVD. KVM works.
  3. Make sure no adb server is running (fresh WSL boot, or adb kill-server).
  4. Open the Device panel, or call device_list.

Expected behavior

The AVD is listed. adb starts its server on first use and the hub answers.

Actual behavior

device_list reports "The device hub did not answer within 40 seconds." with incompletePlatforms: ["android"] and lists no Android devices. GET /api/devices on the hub hangs.

The hub's adb devices -l children sit in SYN-SENT to 127.0.0.1:5037. Under mirrored networking, a connect to an unbound 127.0.0.1 port is not refused. It hangs until the SYN retries run out (about 2 minutes), and only then does adb fork its server. 127.0.0.2 and ::1 refuse immediately, and no firewall rule drops the traffic:

$ timeout 10 bash -c 'exec 3<>/dev/tcp/127.0.0.1/47123'   # closed port
(hangs, rc=124 after 10s)
$ timeout 5 bash -c 'exec 3<>/dev/tcp/127.0.0.2/47123'
bash: connect: Connection refused   # 0.00s

A related effect of the same mode: if any Windows process starts adb.exe first, it owns port 5037 for both sides. WSL's adb client and the hub then talk to the Windows adb server, which drives the WSL emulator over the shared localhost. In my case adb shell calls through it hung and the hub timed out the same way.

Impact

On WSL with mirrored networking (the mode needed for most localhost tooling), Android devices don't appear after every WSL boot until something else starts an adb server. The error doesn't point at adb, so it looks like a hub failure.

Version or commit

0.1.10-nightly.20261114.4709, expo-device-hub 0.22.1, adb 37.0.1

Environment

Windows 11, WSL2 kernel 6.18.58.1, Ubuntu, networkingMode=mirrored, systemd enabled, T3 server as a systemd user service.

Logs or stack traces

{"hostStatuses":{"local":{"status":"ready","detail":"The device hub did not answer within 40 seconds.","incompletePlatforms":["android"]}}, ... "devices":[]}

$ ss -tnp | grep 5037
SYN-SENT 0 1 127.0.0.1:37533 127.0.0.1:5037 users:(("adb",pid=7670,fd=3))
SYN-SENT 0 1 127.0.0.1:38955 127.0.0.1:5037 users:(("adb",pid=4891,fd=3))

Workaround

Run an adb server before the hub needs it, which skips adb's connect-then-fork probe. A systemd user unit works:

[Service]
ExecStart=%h/Android/Sdk/platform-tools/adb nodaemon server
Restart=on-failure

With it running, /api/devices answers in under a second and the emulator boots and streams normally.

A possible fix in T3: on Linux, have LocalDeviceHost start and supervise adb nodaemon server (on the resolved SDK's adb) next to the hub when port 5037 is not already listening, instead of relying on adb's auto-start.

Activity

  1. Dopetaiga commented on Nov 17, 2026

    @Dopetaiga

    Confirming the mechanism: this matches the known mirrored-mode loopback behavior where the first SYN to an unbound 127.0.0.1 port is dropped instead of refused, so adb's connect-then-fork probe waits out its TCP retransmits before the server ever forks. 127.0.0.2 and ::1 take a different path and refuse immediately, as your measurements show. On NAT mode the same first-use works because an unbound port answers RST locally.

    Your systemd workaround isolates the bug to adb's probe, and I agree the hub should own the server: have LocalDeviceHost start and supervise adb nodaemon server (on the resolved SDK's adb) when nothing is listening on 5037, and leave an already-running server — including one owned by a Windows adb — untouched.

    Checked the open device-hub PRs: #27525 resolves a system adb, #23498 isolates slow hosts, #30629 trims emulator-tool discovery — none prewarm the server, so this is uncovered.

    Reproducing now on Windows 11 + WSL2 (Ubuntu 24.04, mirrored, fresh boot + adb kill-server) and taking the prewarm fix.

  2. Dopetaiga commented on Nov 17, 2026

    @Dopetaiga

    Opened #37953 for the prewarm fix.

    While checking whether I could reproduce the hang itself, my environment came out healthy at the same kernel as yours (WSL 3.0.5, kernel 6.18.58.1-1, mirrored, cold boot, adb 37.0.1): an unbound 127.0.0.1 port refuses immediately here, and 127.0.0.2 behaves the same way your measurements show. So the mirrored relay defect the hang rides on looks environment-specific beyond the WSL version.

    Could you share your wsl --version full output (WSL/MSRDC versions especially), the Windows build (winver), and whether anything third-party sits on loopback traffic (VPN, filter driver, security software)? That would pin which machines the prewarm needs to cover, and possibly a separate WSL issue upstream.

    One more detail from this side, in case it helps your diagnosis: in the other direction (Windows process connecting to a WSL-side port), mirrored loopback accepted a connect to a port nothing was listening on — Node's connect succeeded while netstat and ss showed no listener anywhere. So the same relay lies in both directions, just with opposite symptoms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions