Skip to content

[Bug]: WSL backend stuck connecting when Windows can't reach the WSL NAT IP #13738

Open

Description

@Ganboo

Before submitting

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

Area

apps/desktop

Steps to reproduce

  1. On Windows with WSL2 in default NAT networking, run a host where Windows → WSL NAT-IP HTTP is filtered but WSL localhost forwarding works (in my case a corporate endpoint security client intercepts traffic to private ranges).
  2. Enable Settings → WSL backend (dual mode, "WSL only" off) and pick a distro.
  3. Open the command palette and look for Open WSL folder, or try adding a Linux project.

Expected behavior

The desktop connects to the WSL backend and the WSL environment becomes usable, like VS Code/Cursor Remote-WSL on the same machine.

Actual behavior

The WSL backend process starts and is healthy, but the desktop never marks it ready. resolveWslStartConfig sets httpBaseUrl to the distro's hostname -I IP in NAT mode, and every readiness probe to it fails. "Open WSL folder" never appears and WSL projects can't be added.

Measured from the same Windows host against the same backend:

From URL Result
inside WSL http://<wsl-nat-ip>:3774/.well-known/t3/environment 200 in 4ms
Windows http://127.0.0.1:3774/... (wslhost forwarding) 200 in 81ms
Windows http://<wsl-nat-ip>:3774/... (what the desktop uses) TCP connects, then "connection closed unexpectedly" after ~3.7s

Routing is correct (the WSL NAT subnet routes via vEthernet (WSL (Hyper-V firewall)), and eth0 is the default route in the distro), so this isn't the wrong-interface case from #5211. The right IP is chosen but isn't reachable over HTTP from Windows.

For comparison, Cursor's Remote-WSL (anysphere.remote-wsl 1.0.13) on the same machine binds its server to 127.0.0.1 inside WSL and always connects from Windows through http://127.0.0.1:<port>, and it works.

Impact

Blocks work completely

Version or commit

0.0.43-nightly.20260925.2269 (also reproduced on the previous stable release); code path unchanged on main @ 2a9832b80

Environment

Windows 11 Enterprise, WSL2 NAT mode (no .wslconfig), Ubuntu 24.04 distro, T3 Code desktop (dual mode: Windows primary + WSL secondary)

Logs or stack traces

# desktop.trace.ndjson — thousands of these, never succeeding
http.client GET http://<wsl-nat-ip>:3774/.well-known/t3/environment  exit: Failure
# server-child-wsl_<distro>.log — backend itself is healthy
Listening on http://0.0.0.0:3774

Screenshots, recordings, or supporting files

No response

Workaround

Switching WSL to networkingMode=mirrored should make the desktop use loopback, but it changes networking for every distro.

I have a small fix on a branch that I can open as a PR if you want it. For WSL NAT runs it dials 127.0.0.1 first, as VS Code and Cursor do, and keeps the distro IP as a readiness fallback, so hosts where wslhost forwarding is unreliable (the reason for the current behavior) still connect. It's about 60 source lines in DesktopBackendConfiguration.ts and DesktopBackendManager.ts, with focused tests, and I've verified it end to end on the affected machine.

Activity

  1. added
    bug
    needs-triage
    on Sep 26, 2026
  2. Ganboo commented on Sep 26, 2026

    @Ganboo
    Author

    Related

  3. juliusmarminge commented on Sep 26, 2026

    @juliusmarminge
    Member

    The diagnosis matches current main (unchanged in these files since 2a9832b80). In default WSL2 NAT mode, resolveWslStartConfig advertises the distro address from getDistroIp (hostname -I's first IPv4, when that address is not on a Windows interface). waitForHttpReady probes only that URL and retries until it answers, so the WSL environment never connects and "Open WSL folder" stays hidden. The backend can still be healthy on 0.0.0.0, and Windows 127.0.0.1 via wslhost is simply never tried.

    That NAT URL is deliberate. The comment in resolveWslStartConfig records hosts where wslhost forwarding fails and only the distro address works. This report is the inverse: endpoint security drops the NAT address, and localhost forwarding works. It is not #5211 (wrong hostname -I entry). That selection bug is still present, but you already checked that the chosen address is the real eth0 route. #5967 was the same splash without this evidence, so this issue should stay the canonical report.

    #9066 does not fix this. It still advertises the NAT address, and in local-only mode it binds only that address, which removes the WSL loopback listener this host needs. #10358 would help a local-only setup by advertising 127.0.0.1, but it gives up the distro-IP fallback that other machines need.

    A small PR is welcome if it stays on this one behavior: keep the 0.0.0.0 bind, probe 127.0.0.1 first, and fall back to the distro IP when loopback does not answer. The URL that succeeds has to be the one the renderer keeps using. Please include a test for each order, and leave #9056's bind-host change out of it. networkingMode=mirrored remains a working workaround because that mode already forces loopback.

  4. added
    via-triage
    accepted
    and removed
    needs-triage
    on Sep 26, 2026
  5. Ganboo commented on Sep 26, 2026

    @Ganboo
    Author

    Thanks @juliusmarminge made some adjustments and linked my PR above.

    Let me know if any changes are necessary.

  6. added
    needs more info
    and removed
    needs more info
    on Oct 22, 2026
  7. rntjr commented on Nov 7, 2026

    @rntjr

    Another trigger for the same symptom: ufw enabled inside the WSL distro. Same mechanism as described here (Windows can't reach the distro NAT IP, loopback works), but the block is the Linux firewall rather than endpoint security on Windows.

    Environment: T3 Code desktop 0.1.7 on Windows, WSL backend enabled, WSL2 default NAT networking, ufw active in the distro (default policy INPUT DROP; only 22/tcp and 60000:61000/udp allowed).

    Repro:

    1. In the distro: sudo ufw enable (default rules)
    2. Enable the WSL backend in the desktop app and restart it. It hangs on "Connecting to WSL…" indefinitely, with no error.

    Diagnostics:

    • The WSL runtime is healthy: ~/.t3/wsl-runtime/sha256-*/t3 --version → t3 v0.1.7. Started by hand, it logs Listening on http://127.0.0.1:3773 and prints a pairing URL.
    • From Windows: curl.exe http://localhost:3773/.well-known/t3/environment → works (wslhost forwarding)
    • From Windows: curl.exe http://<distro-ip>:<port> → timeout (curl: (28) after ~21 s), even against python3 -m http.server 8000 --bind 0.0.0.0, so it's not T3-specific
    • From Windows: ping <distro-ip> → works. ufw allows ICMP echo-request, which makes the network look fine.
    • Hyper-V firewall ruled out: Get-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' → DefaultInboundAction: Allow; no Block rules in Get-NetFirewallHyperVRule. No VPN involved.
    • In the distro: sudo iptables -S → -P INPUT DROP with the ufw chains; only --dport 22 (tcp) and 60000:61000 (udp) accepted

    Workaround:

    sudo ufw allow from 172.16.0.0/12 to any port 3773:3790 proto tcp

    Alternatives: sudo ufw disable, networkingMode=mirrored, or run the backend manually and connect as a remote environment over localhost.

    The loopback-first probe proposed here would fix this case too. It would also help if the desktop showed a hint after N seconds of failed readiness probes (e.g. "backend started but its distro IP isn't reachable from Windows; check ufw/iptables inside WSL or endpoint security on Windows") instead of an endless spinner.

  8. Carvalh0XYZ commented on Nov 13, 2026

    @Carvalh0XYZ

    Another trigger for the same symptom: the WSL Hyper-V firewall blocks inbound traffic to the VM by default on some managed Windows machines.

    Environment: T3 Code Nightly 0.1.10-nightly.20261113.4643 (Electron 44.10.1) on Windows 11, WSL backend in WSL-only mode, WSL2 default NAT networking. Ubuntu distro without ufw. No VPN in the path; the Global Secure Access forwarding profile bypasses 172.16.0.0/12.

    Symptom: the desktop stays on "Connecting to WSL…". desktop.trace.ndjson shows GET http://172.17.2.191:3773/.well-known/t3/environment interrupted every second. The WSL server is healthy and listens on 0.0.0.0:3773.

    Diagnostics (before the fix):

    • Windows → http://127.0.0.1:3773/.well-known/t3/environment: 200 (wslhost forwarding)
    • Windows → http://172.17.2.191:3773/...: timeout. Test-NetConnection -Port 3773 → False
    • Windows → ping 172.17.2.191: works, so the network looks fine
    • In the distro, no SYN from 172.17.0.1 reaches port 3773 (no syn-recv entries during the attempt)
    • Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore → Name {40E0AC32-46A5-438A-A0B2-2B479E8F2E90}, DefaultInboundAction: Block

    Workaround (elevated PowerShell):

    New-NetFirewallHyperVRule -Name "T3Code-WSL-Backend" -DisplayName "T3 Code WSL backend (TCP 3773-3790)" `
      -Direction Inbound -VMCreatorId "{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}" `
      -Protocol TCP -LocalPorts "3773-3790" -Action Allow

    After the fix: Windows → http://172.17.2.191:3773/.well-known/t3/environment returns 200 in 6 ms, the desktop readiness probe succeeds, and the app connects to the WSL backend.

    This is a third cause besides endpoint security and ufw in the distro. All three leave loopback working, so the loopback-first probe from #13745 would fix each of them without a firewall change. #13745 was closed because nobody had a Windows/WSL2 machine for the proof. This machine reproduces the base failure reliably: remove the Hyper-V rule to make the distro IP unreachable while localhost still works. I can test a fresh PR on it.

  9. Karthik-beta commented on Nov 14, 2026

    @Karthik-beta

    Opened #36833 with the scope described above:

    • Keeps the 0.0.0.0 bind and probes 127.0.0.1 first. The distro IP is a fallback in NAT mode only; mirrored mode has no fallback, as before.
    • If loopback doesn't answer, the distro IP is used. The renderer keeps the URL that answered, including across restarts until the new run is ready.
    • Tests cover each probe order: only loopback answers, only the distro IP answers, and both answer with loopback slower. There's also a restart case.
    • [Bug]: WSL backend binds 0.0.0.0 while "Network access" is off and the UI says "Limited to this machine" #9056's bind-host change is left out.

    I tested it on Windows 11 with WSL2 in NAT mode, with the distro IP blocked from Windows. The current code timed out probing only the distro IP. With the fix, the app connected over loopback.

    This builds on #13745 by @Ganboo, who is credited as co-author.

  10. Couiz commented on Nov 15, 2026

    @Couiz

    Another trigger for the same symptom: Docker bridges inside the distro make mirrored mode look like NAT.

    Environment: T3 Code Nightly 0.1.10-nightly.20261115.4736 on Windows 11, dual mode (Windows primary + WSL backend), Ubuntu-24.04, .wslconfig with networkingMode=mirrored, Docker Engine installed in the distro.

    Symptom: after an app restart the WSL environment never connects and all its threads disappear from the UI. The backend child log ends with:

    Timed out after 180000ms waiting for desktop backend readiness at http://172.24.0.1:3774/.well-known/t3/environment.
    

    Diagnostics:

    • The WSL server is healthy and listens on 0.0.0.0:3774. Windows → http://127.0.0.1:3774/.well-known/t3/environment returns 200.
    • hostname -I in the distro printed the Docker bridges first, then the mirrored addresses:
      172.24.0.1 172.18.0.1 ... 172.17.0.1 10.10.0.2 192.168.0.164
      docker0 and br-* have lower interface indexes than the mirrored eth* interfaces. All bridges were DOWN (no containers running).
    • getDistroIp takes the first IPv4 (172.24.0.1). It is not on a Windows interface, so isLocalHostIpv4 is false and the desktop dials the bridge address instead of 127.0.0.1. That address is not reachable from Windows.
    • Earlier sessions on the same machine used 127.0.0.1 and worked; the address order differed then.

    So here the mirrored-mode check fails because it looks only at the first address, not because of a firewall. Probing 127.0.0.1 first, as #36833 does, should cover this case too (not tested on this machine).

    Workaround: remove the bridge addresses so a mirrored address comes first, then restart the app:

    docker network prune
    sudo ip addr del 172.17.0.1/16 dev docker0
    

    It comes back after Docker or WSL restarts.

    Investigated by Claude Code (claude-fable-5-2) on the affected machine.

  11. dpearson2699 commented on Nov 30, 2026

    @dpearson2699

    Reproduced on the latest nightly with mirrored WSL and Tailscale

    Environment: T3 Code 0.1.14-nightly.20261130.5465 (win32 x64), WSL2 Ubuntu 26.04, mirrored networking (wslinfo --networking-mode reports mirrored), Tailscale in both Windows and WSL, and T3 Code in WSL-only mode.

    1. Start T3 Code with the WSL Tailscale IPv4 address listed first in hostname -I, ahead of the mirrored addresses.
    2. The app stays on the logo splash screen even though the WSL backend is listening.
    3. From Windows, request the backend on its active port. http://127.0.0.1:3773/ returned HTTP 200. The same request to the WSL Tailscale IP timed out from Windows and returned 200 from inside WSL.

    The desktop bridge reported the WSL Tailscale IP as the primary backend URL. The desktop's local bearer-token request remained pending during testing. In this build, getDistroIp takes the first IPv4 from hostname -I. Because the first address belongs only to the WSL Tailscale interface, the Windows-interface check in resolveWslStartConfig doesn't select localhost. This looks like the mirrored-mode case reported above with Docker bridges, with tailscale0 supplying the first address.

    I tested a local change to use 127.0.0.1 for the WSL backend URL. The token request succeeded and the desktop opened to the normal UI with the New Thread control. This also worked after a normal relaunch. That verifies the loopback path on this setup and is relevant to #36833.

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

    acceptedbugvia-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions