Skip to content

[Bug]: Desktop stuck on "Connecting to WSL" — getDistroIp picks unreachable Docker bridge IP instead of eth0 #5211

Closed

Description

@9jaGuy

Summary

Desktop WSL backend hangs on "Connecting to WSL..." forever. getDistroIpImpl (apps/desktop/src/wsl/DesktopWslEnvironment.ts:691) assumes the first IPv4 in hostname -I output is always the reachable eth0 address. When Docker has created bridge networks in the distro, those sort first and are never reachable from Windows — so the app polls a dead address forever.

Environment

  • T3 Code (Alpha) 0.0.31, Windows desktop
  • WSL2 Ubuntu, networkingMode=mirrored
  • Docker running inside the distro with active bridge networks

Repro

  1. WSL2 + mirrored networking + any docker compose project running (creates a bridge network).
  2. Enable WSL backend (wslBackendEnabled/wslOnly: true) and restart T3 Code.
  3. Stuck on "Connecting to WSL..." indefinitely; restarting doesn't help, same bad IP gets picked every time.

Root cause

// apps/desktop/src/wsl/DesktopWslEnvironment.ts:691
const candidate = raw.split(/\s+/).find((part) => IPV4_PATTERN.test(part));

hostname -I returned (example): 172.22.0.1 172.19.0.1 172.17.0.1 192.168.1.219 — the first three are Docker bridge IPs (internal to the WSL VM, never reachable from Windows in any networking mode); the last is the real mirrored eth0 IP, confirmed reachable. The code takes the first match, so it grabs a Docker bridge address whenever one exists.

Confirmed the backend itself was healthy the whole time (listening on 0.0.0.0:3773, curl 127.0.0.1:3773/.well-known/t3/environment → 200 from both WSL and Windows) — this is purely an address-resolution bug, distinct from #3611.

docker network prune doesn't fix it long-term — it just makes the code pick the next Docker bridge IP in the list instead.

Suggested fix

  • Prefer 127.0.0.1 for the readiness check under mirrored networking (already works), or
  • Resolve the actual default-route interface inside WSL (ip route show default) instead of trusting hostname -I ordering.
  • At minimum, log the full candidate list and which one was chosen.

Workaround

None without tradeoffs — any Docker bridge network breaks this, and disabling wslBackendEnabled defeats the feature.

Activity

  1. 9jaGuy commented on Aug 11, 2026

    @9jaGuy
    Author

    Update: worked around this by disabling wslOnly (native-Windows backend connected reliably, no WSL bridge involved). Re-enabled wslBackendEnabled afterward and it's now also connecting fine in the parallel WSL+Windows ("mixed") backend mode — so whatever was stalling the WSL cold start on my end has since cleared.

    Separate observation worth flagging: while chasing this, I also hit cases where the WSL-hosted backend eventually did become reachable on 127.0.0.1 (confirmed via curl, and via /proc/<pid>/wchan showing it stuck in p9_client_rpc — WSL's /mnt/c/ filesystem bridge — rather than crashing), but past the 60s waitForHttpReady deadline. The desktop app never re-polled that already-spawned backend afterward and stayed on the connecting spinner until a manual restart. That's a second, independent gap from the IP-selection bug above: no retry/re-check against a backend that recovers after the readiness deadline.

  2. 9jaGuy commented on Sep 22, 2026

    @9jaGuy
    Author

    Closing this out — resolved on my end (T3 now connects reliably in mixed WSL+Windows backend mode). Leaving the diagnosis above in case it's useful if this resurfaces for someone else; the underlying getDistroIp IP-selection issue wasn't fixed upstream, just no longer hitting it here.

  3. dvadovsz commented on Nov 6, 2026

    @dvadovsz

    Still reproduces on T3 Code (Beta), server 0.1.7, Windows 11 arm64, with networkingMode=mirrored. Docker Engine runs natively in the distro. The #13738 thread says mirrored mode already forces loopback, but that did not happen here.

    wsl.exe -d Ubuntu -- sh -c "hostname -I" prints 172.17.0.1 (docker0, interface DOWN) first, then the real eth0 and eth2 addresses. T3 probes http://172.17.0.1:3774/.well-known/t3/environment and times out at 60 s, then 180 s. The backend listens on 0.0.0.0:3774, and http://127.0.0.1:3774/... returns 200 from Windows.

    Workaround until a fix lands: put a hostname wrapper in /usr/local/bin, which precedes /usr/bin in the PATH that wsl.exe ... sh -c uses. It prints loopback for hostname -I only:

    sudo install -m 755 /dev/stdin /usr/local/bin/hostname <<'EOS'
    #!/bin/sh
    if [ "$1" = "-I" ] && [ "$#" -eq 1 ]; then
      echo 127.0.0.1
      exit 0
    fi
    exec /usr/bin/hostname "$@"
    EOS

    Fully quit T3 Code, including the tray, and relaunch. The backend became ready right away. The mode must be 755: with sudo tee plus chmod +x under umask 027 the file ended up rwxr-x---, and the shell silently skipped it. Remove the file to undo it. Any script that relies on hostname -I will now see 127.0.0.1.

    The #5998 idea of probing 127.0.0.1 alongside the distro addresses would also fix this. Skipping docker0, br-* and veth* entries would fix the selection part.

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