Live debugging: how remote services reach your machine, and what to check when a page will not open
This page covers a service running in the remote DSH that you want in your local browser: why it appears, what address it gets, when it disappears, and where to look when it will not open.
Prerequisite: dsh-devtools in the remote DSH
Automatic forwarding depends on a port snapshot: every second the companion plugin records which ports DSH's descendant processes are listening on, writing it to ~/.dsh/storages/devtools_ports.json; the client reads it every four seconds.
dsh plugin --profile web add @zhangzhian/dsh-devtools
Restart DSH afterwards; a client-installed runtime already includes it. Without the plugin — or when the snapshot cannot be read — no automatic rules are created, and the status line says "Cannot read the port snapshot". Existing rules are still checked.
The rule: ownership × liveness
Both must hold before a rule exists:
| Condition | Meaning | Source |
|---|---|---|
| Ownership | The port grew out of DSH's process tree | The plugin's snapshot (process ancestry) |
| Liveness | Something is genuinely listening right now | The client enumerates the remote listening table |
Started from the run panel with ▶ counts; so does pnpm run dev typed into a DSH terminal. Services that were already running before you connected are found too. Liveness alone would forward services you never asked for; the snapshot alone would keep a dead port for a moment. You need both.
Reading the status line
Under Settings → Automatic port forwarding the line reports both sides:
dsh started 2 runs and claimed 3 ports (1 of them from terminals); 5 listening remotely; 1 auto-forwarded
"N auto-forwarded" means both conditions held. "N more rules are only being checked against the remote host" covers manual rules and non-matching ones. The line may add "N opened this round", "N disappeared ports cleared" or "limit of 8 reached".
Three kinds of "invisible" are distinct, and the last two never clear a rule: owned: [] means probed and genuinely empty; owned: null means this round produced no answer; an unreadable file means the plugin is missing.
Local ports: same number first
Remote 3000 becomes local 3000, so localhost:3000, bookmarks and OAuth callbacks keep working. If the number is taken, an automatic rule falls back to its last assigned port, then to one the system picks; a rule whose local port you fixed reports "local port X is already in use" rather than changing silently.
Remote ports below 1024 are forwarded too, but reusing the number locally depends on the platform: Windows binds 82 directly, Linux tries and falls back, macOS uses a high port.
Ports that are never auto-forwarded
- SSH itself (22 / 2222).
- The DSH Web port (3080).
- Addresses bound to a specific interface, such as
192.168.1.5:8081— unreachable on the remote loopback, so forwarding only yields 502s.
Services bound to 0.0.0.0 / :: are forwarded (Spring Boot's default), and so are remote 80 / 82 / 443.
Rules first, tabs only if you ask
By default discovery records rules in the background; you decide when to open a page. To let it open tabs for you, turn on Settings → Automatic port forwarding → "Open tabs automatically when forwarding" (off by default). The first round after launch does not grab a tab before the DSH page appears.
Manual and static rules
When discovery cannot see a service, add a rule under Settings → Forwarding rules → +: a local port plus a remote host:port, with 0 to let the system choose. Manual rules do not need the plugin. To keep one forever, mark it static on the rule card: it survives the service disappearing and is never cleaned up automatically.
When rules get cleared
- Once a remote port stops listening, rules pointing at it are removed and their tabs closed.
- Hand-written rules are checked the same way; only static rules and the DSH default entry are exempt.
- Removal needs three consecutive misses (4-second rounds); new or edited rules get a 5-minute grace period. After removal comes a 2-minute cooldown; a returning service is forwarded again the same round.
- Nothing is cleared while SSH is disconnected.
When a page will not open
Always in the same order: the failure on the page → the rule state → the [dsh remote] log.
- The 502 page states the reason, e.g.
connect ECONNREFUSED 127.0.0.1:5173. - The rule shows listening / starting / failed / not started.
- The terminal log holds the probe and the failure.
Common cases:
- Host / Origin checks. Host rewriting has four modes — to
127.0.0.1:<local port>(recommended), to the remote address, off, or custom — and Origin can be rewritten too. Vite'sallowedHostsand DSH's Origin check need no extra configuration. - HMR (hot module replacement) needs no setup: the connection is transparent TCP forwarding, so HTTP and WebSocket are byte streams.
- 401 / Basic authentication. The app raises its own sign-in box; "Remember password" stores the credential in the system key store.
- HTTPS targets. TLS bytes are passed through, so the page opens at
https://127.0.0.1:<port>; certificate mismatches are allowed for loopback only, and Host rewriting does not apply because the Host is inside TLS. - Multiple tabs. The DSH page and any forwarded page can be open together, with an address bar and back / forward / reload.
Three kinds of services it cannot see
- Started outside DSH with
nohup, pm2, systemd, screen or tmux: the process ancestry is broken. - DSH in a container while you connect to the host (or the reverse): different namespaces; a non-root
lsofalso sees only the same user's sockets. - Bound to a specific interface: unreachable on the remote loopback.
For all three, add a rule by hand.
Next
- Nothing connects: SSH troubleshooting
- Why it works: Port forwarding
- The plugin: dsh-devtools
- The product: What is DSH Remote?
Did this page help?
If something is still unclear, tell us and we will fix this page.
In a hurry? Email works too.