[Bug]: Desktop stuck on "Connecting to WSL" — getDistroIp picks unreachable Docker bridge IP instead of eth0 #5211
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#
- WSL2 + mirrored networking + any
docker composeproject running (creates a bridge network). - Enable WSL backend (
wslBackendEnabled/wslOnly: true) and restart T3 Code. - 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.1for the readiness check under mirrored networking (already works), or - Resolve the actual default-route interface inside WSL (
ip route show default) instead of trustinghostname -Iordering. - 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.
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.
9jaGuy(GitHub profile, opens in a new tab) closed this
Still reproduces on T3 Code (Beta), server 0.1.7, Windows 11 arm64, with
networkingMode=mirrored. Docker Engine runs natively in the distro. The#13738thread says mirrored mode already forces loopback, but that did not happen here.wsl.exe -d Ubuntu -- sh -c "hostname -I"prints172.17.0.1(docker0, interface DOWN) first, then the real eth0 and eth2 addresses. T3 probeshttp://172.17.0.1:3774/.well-known/t3/environmentand times out at 60 s, then 180 s. The backend listens on0.0.0.0:3774, andhttp://127.0.0.1:3774/...returns 200 from Windows.Workaround until a fix lands: put a
hostnamewrapper in/usr/local/bin, which precedes/usr/binin the PATH thatwsl.exe ... sh -cuses. It prints loopback forhostname -Ionly: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 "$@" EOSFully quit T3 Code, including the tray, and relaunch. The backend became ready right away. The mode must be 755: with
sudo teepluschmod +xunder umask 027 the file ended uprwxr-x---, and the shell silently skipped it. Remove the file to undo it. Any script that relies onhostname -Iwill now see127.0.0.1.The
#5998idea of probing127.0.0.1alongside the distro addresses would also fix this. Skippingdocker0,br-*andveth*entries would fix the selection part.
Sign in to join this conversation.
Update: worked around this by disabling
wslOnly(native-Windows backend connected reliably, no WSL bridge involved). Re-enabledwslBackendEnabledafterward 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 viacurl, and via/proc/<pid>/wchanshowing it stuck inp9_client_rpc— WSL's/mnt/c/filesystem bridge — rather than crashing), but past the 60swaitForHttpReadydeadline. 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.