Skip to content

[Bug]: Remote port forwarding fails with LoopbackTunnelUnavailableError for a server bound to dual-stack IPv6 (::) #39546

Closed as not planned

Description

@claytonfaria

Before submitting

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

Area

Not sure

(Remote port forwarding, added in #39393.)

Steps to reproduce

  1. Connect the desktop app (Linux) to a remote environment.
  2. In a project on the remote, add this t3.json:
    {
      "$schema": "https://t3.codes/schema/t3.json",
      "scripts": [
        {
          "name": "Preview site",
          "command": "python3 scripts/serve.py 8080",
          "previewUrl": "http://localhost:8080",
          "autoOpenPreview": true
        }
      ]
    }
    and this scripts/serve.py, which binds a dual-stack IPv6 socket (:: with IPV6_V6ONLY = 0):
    import errno, functools, http.server, socket, sys
    from pathlib import Path
    DIST = Path(__file__).resolve().parent.parent / "dist"
    PORT = int(sys.argv[1]) if len(sys.argv) > 1 else 8080
    class NoCacheHandler(http.server.SimpleHTTPRequestHandler):
        def end_headers(self):
            self.send_header("Cache-Control", "no-store")
            super().end_headers()
    class DualStackServer(http.server.ThreadingHTTPServer):
        address_family = socket.AF_INET6
        def server_bind(self):
            self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
            super().server_bind()
    if __name__ == "__main__":
        handler = functools.partial(NoCacheHandler, directory=str(DIST))
        server = DualStackServer(("::", PORT), handler)
        with server:
            print(f"Serving {DIST} at http://localhost:{PORT}", flush=True)
            server.serve_forever()
  3. Run the "Preview site" script.
  4. Try to forward port 8080 using remote port forwarding.

Expected behavior

Port 8080 is forwarded to the local machine, the same as for other servers on that remote.

Actual behavior

Forwarding fails with:

This environment can't be reached right now. Try again once it reconnects.

(LoopbackTunnelUnavailableError)

The environment is connected and working. On the same remote, at the same time:

  • The in-app browser preview of http://localhost:8080 loads the site.
  • Forwarding a basic Vue/Vite npm run dev server works.
  • Changing only the bind in serve.py from DualStackServer(("::", PORT), handler) to http.server.ThreadingHTTPServer(("0.0.0.0", PORT), handler) makes forwarding work.

So the failure depends on the remote server binding :: (dual-stack). The error message is misleading, because the environment is reachable.

Impact

Minor bug or occasional failure

Version or commit

v0.1.11-nightly.20261120.4969 (db51b67)

Environment

Client: desktop app on Linux. Remote: a remote environment.

Workaround

Bind the dev server to IPv4 (0.0.0.0) instead of ::.

Activity

  1. juliusmarminge commented on Nov 20, 2026

    @juliusmarminge
    Member

    @claytonfaria How is your desktop app connected to that remote environment: over SSH (Add environment > SSH), a remote link by LAN or Tailscale address, or T3 Connect? And does the forward fail every time while the dual-stack server runs, and succeed every time once you switch it to 0.0.0.0?

  2. added
    needs more info
    on Nov 20, 2026
  3. claytonfaria commented on Nov 20, 2026

    @claytonfaria
    Author

    @juliusmarminge tried with T3 Connect and also with Tailscale (found automatically). Yes 0.0.0.0 works every time and dual-stack fails everytime. For my use case i just removed the ipv6 and all working ok

  4. removed
    needs more info
    on Nov 20, 2026
  5. juliusmarminge commented on Nov 20, 2026

    @juliusmarminge
    Member

    I tried to reproduce this on the current build and could not.

    Commit 59651c1 (origin/main). Ran the remote T3 server (node apps/server/src/bin.ts serve --host 10.239.46.2 --port 3773) inside its own Linux network namespace, joined to the host by a veth pair, so its loopback is separate from the desktop's. In the remote's project dir: the reporter's exact scripts/serve.py (binds :: with IPV6_V6ONLY=0) and t3.json. Ran the real desktop app (vp run dev:desktop under headless-desktop, T3CODE_DEV_SEED=0) and paired it through Settings > Connections > Add environment > Remote link (http://10.239.46.2:3773 + pairing code); it showed Connected. With the dual-stack server listening on *:8080 in the remote namespace: (1) a driver that copies LoopbackTunnel.probeLoopback against /api/preview/tunnel got 502 with x-t3-tunnel-port-refused for the random probe port (3/3 runs), and port=8080 opened the tunnel and returned HTTP/1.0 200 OK; (2) in the desktop renderer, window.desktopBridge.preview.sharesLoopback(env) returned false in 28 ms and forwardPort(env, 8080) returned {remotePort:8080, localPort:8080}; (3) through the UI, Command palette > Forwarded ports > typing 8080 > 'Forward port 8080 from ' showed the toast 'Forwarded port 8080 – Apps on this machine reach it at localhost:8080'. curl to localhost:8080, 127.0.0.1:8080 and [::1]:8080 on the desktop machine all returned 200 from the remote's dual-stack server. No LoopbackTunnelUnavailableError at any point. Not tested: the T3 Connect route, and an HTTPS Tailscale Serve route (I used a plain-HTTP remote link by address, as the reporter's auto-found Tailscale link does). Also not tested: running the script through the T3 script runner with autoOpenPreview opening the in-app preview at the same moment. No relevant commits between the reporter's build db51b67 and main in LoopbackTunnel.ts, PreviewTunnel.ts, portForwards.ts or previewTunnel.ts.

    Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.

  6. shivamhwp commented on Nov 20, 2026

    @shivamhwp
    Collaborator

    [Haiku 5.5][Claude Code] on behalf of shivam.

    Thanks for the detail. We reproduced the forward path with a real Python dual-stack server behind the real tunnel route, and the bind family alone didn't change the result. What did change it is the probe response: when the environment's tunnel answers the port probe without the x-t3-tunnel-port-refused header, the desktop app reports "can't be reached" for both 0.0.0.0 and ::. So we need to know what your environment actually returns for the probe.

    Could you send, from the failing :: run:

    1. The status code and response headers of the /api/preview/tunnel?port=<number> request in the environment's server log (or the failing request in DevTools, if that is easier), and in particular whether x-t3-tunnel-port-refused is present.
    2. Whether the environment runs behind a proxy, relay, or load balancer in front of the T3 server (T3 Connect, Tailscale Serve, nginx, Cloudflare, or none).

    That will tell us whether the tunnel reaches the environment and gets a refusal, or whether a layer in between drops the header.

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