t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: SSH environment: no port forwarding — loopback dev servers (localhost:5173) unreachable from the client and the preview panel

Open bignosecss opened this issue 1 month ago • 0 comments

Before submitting

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

Area

apps/desktop

Steps to reproduce

  1. On macOS, add an SSH environment pointing at a remote Ubuntu machine and let T3 Code launch its managed server there (remote server reported 0.1.4, listening on 127.0.0.1:3773).
  2. In a thread terminal on the remote, start a dev server that binds loopback only: pnpm dev:web → Vite prints Local: http://localhost:5173/ and listens on 127.0.0.1:5173 (Vite's default host: localhost).
  3. Open the printed URL from the thread (terminal link / preview panel).
  4. Also paste http://localhost:5173/ into Chrome on the macOS client.

Expected behavior

A remote dev server reachable at 127.0.0.1:5173 on the SSH host should be reachable from the client, the way VS Code Remote-SSH handles it: the client's localhost:5173 is forwarded over the existing SSH connection to the remote's 127.0.0.1:5173, so:

  • the in-app preview panel can load the page,
  • terminal links resolve to a target that actually works,
  • opening the URL in the client's own browser (or an "open externally" action) hits a forwarded local port.

Forwarding on demand from the discovered local servers (like VS Code's ports view, auto-forward on discovery) would be even better.

Actual behavior

  • Client browser: localhost:5173 → ERR_CONNECTION_REFUSED. The URL resolves on the Mac, where nothing listens.
  • The in-app preview panel cannot load it either; it does not reach the remote loopback.
  • The SSH tunnel appears to carry only the T3 server port. From reading packages/ssh/src/tunnel.ts, the -L forward is created for the managed server port (3773) only; the remote port scanner (apps/server/src/preview/PortScanner.ts) discovers the dev server, but nothing exposes that port to the client.
  • Suggested fix is not the user's job, but the shape that would match VS Code: forward each discovered remote loopback port on demand / automatically, and rewrite loopback preview targets through the forward.

Remote side for reference — both listeners are loopback-only:

$ ss -ltnp | grep -E ':5173|:3773'
LISTEN 0 511 127.0.0.1:3773 0.0.0.0:* users:(("node-MainThread",pid=574153,fd=23))
LISTEN 0 511 127.0.0.1:5173 0.0.0.0:* users:(("MainThread",pid=579997,fd=29))

Impact

Major degradation or frequent failure

Version or commit

Remote managed server 0.1.4 (SSH environment); desktop app connected from macOS.

Environment

  • Client: macOS, T3 Code desktop, SSH environment.
  • Remote: Ubuntu 24.04.5 LTS, Node 24.22.1, pnpm 12.15.0.
  • Dev server: Vite 8.0.15 via pnpm dev:web, bound to 127.0.0.1:5173 (default).
  • Not a WSL setup; this is a genuine SSH environment, so the WSL-specific resolution from #13444 does not apply.

Logs or stack traces

No response

Screenshots, recordings, or supporting files

No response

Workaround

Manual forward in a separate terminal, then open http://localhost:5173/ in the client browser:

ssh -N -L 5173:127.0.0.1:5173 <user>@<remote-host>

Alternatively start the dev server with --host / server.host: '0.0.0.0' and reach it on the remote's LAN/Tailscale address, which weakens isolation and does not work for servers that must stay loopback-only.

bignosecss avatar Oct 29 '26 09:10 bignosecss