Problem#
The desktop app checks whether a remote server runs on the same machine. It asks the server's preview tunnel for a port that nothing on the server listens on, and the server answers 403 Forbidden. Intrusion filters flag that status. The reporter's gateway then drops all traffic to the server for 300 seconds, so the client cannot stay connected.
Change#
A port with no listener now answers 404 Not Found. The x-t3-tunnel-port-refused header and the body stay the same, and desktop and mobile read the header before the status.
502 would also describe it, but Cloudflare replaces an origin 502 with its own page (#39763).
Scope#
Fixes #48028. It is a small fix to one status code.
Missing permission, a disabled tunnel, and the server's own port still answer 403. A port forward that stays open after someone disables the tunnel still gets 403 on each connection. That happens without this change and is not part of it.
Verification#
I reproduced the bug with a Linux server in Docker and the desktop dev app on macOS, then repeated the steps with the fix.
| Step | Before | After |
|---|
| Tunnel request for an empty port | 403 | 404, same header and body |
| Reload the app with a remote thread open | 403 | 404 |
| Restart the server and let the app reconnect | 403 | 404 |
| Same-machine check result | different machine | different machine |
| Suricata 8.0.8 with ET Open rule 2101201, on the captured traffic | alerts | no alerts |
- The updated test for an empty port failed with 403 before the change. The server and desktop tunnel tests pass with it (32 tests), and so does
vp run check:changed.
- The iOS tunnel listener, compiled on macOS, and the Android listener, run on a desktop JVM, both read the 404 as a port failure.
Not checked: a phone or simulator, a Windows client, T3 Connect through Cloudflare, an SSH forward, and a UniFi gateway. The Suricata run shows that the rule no longer fires, not that a gateway keeps the connection.
Model: Claude Sonnet 5.5. Harness: Claude Code in T3 Code.
🤖 Generated with Claude Code
Evidence#
Evidence\n\nSteps on both commits: start the real PreviewTunnel server; bind and close an ephemeral loopback port; request
/api/preview/tunnel?port=<closed-port>; record the HTTP status andx-t3-tunnel-port-refusedheader.\n\n| Before — base3eb58949194ce010be0af51d861d3292127e8a37| After — head9b8ab3815c18b5a173a9834096b6bee609e2e274|\n|---|---|\n| Base capture — observedstatus:403,portRefused:true| Head capture — observedstatus:404,portRefused:true|#Not shown: