In one sentence: DSH Remote maps every port that belongs to a process DSH started and is actually listening right now to
127.0.0.1on your machine, solocalhost:3000is the 3000 on your dev box — no port numbers to remember, nossh -Lto type.
The problem it removes
Services on a dev machine usually bind 127.0.0.1 — reachable only from the machine itself. That default is correct, and it is why your laptop cannot open the page.
The old answer was a hand-written SSH tunnel: ssh -L 3000:127.0.0.1:3000 user@host. It works until it doesn't: you retype ports per environment, a dropped connection kills the tunnel, and HTTPS, 401 auth and Host headers all become your problem.
Port forwarding turns it into rules you can see, and mostly never type.
Three steps
-
Install the companion plugin inside the remote DSH. Only automatic forwarding needs it:
dsh plugin --profile web add @zhangzhian/dsh-devtoolsRestart dsh afterwards. The plugin writes the "which process owns which listening port" snapshot.
-
Start a service inside DSH. Click ▶ in the runs panel, or just type
pnpm run devin a DSH terminal. -
Open the page. A rule appears under Settings → Port forwarding; click Open page. Or do nothing and let it appear.
Manual rules do not need the plugin. Automatic forwarding creates the rule only; tabs are opt-in via a switch that is off by default.
The rule: ownership × liveness
Automatic forwarding is not "the remote has a new port, forward it". That would drag in someone else's database. Two conditions must hold at once:
| Snapshot only | Listening ports only | Ownership × liveness (what DSH Remote does) |
|---|---|---|
| A few hundred milliseconds after a service stops, the snapshot is stale | Every other service on the box gets forwarded too | Ours, and listening right now |
In practice:
- Ownership comes from process lineage. Only descendants of the DSH host process count as ours. The plugin runs
psonce a second, reads the listening table withlsof, intersects the two, and writes the result to~/.dsh/storages/devtools_ports.json. - Liveness is checked by the client. Every 4 seconds it reads that snapshot and confirms the port really is listening remotely.
- Terminal-started services count too. On the chain
dsh → zsh -i → pnpm → nuxt, the process that listens is still a DSH descendant. - Nothing has to be "new". The snapshot describes what is alive now, so services running before you connected are picked up.
If the plugin is missing or the snapshot cannot be read, no automatic rule is created — without ownership information the client will not decide for you. Rules that already exist are still checked against "is it listening on the remote side?".
The status line separates three cases: nothing there (owned: []), this round could not probe (owned: null — treated as blind, so no rule is touched), or the file cannot be read. None of them means "zero ports reported".
Same port first
If the service listens on 3000 remotely, the local entry tries 3000 as well. localhost:3000 in your address bar and bookmarks keeps working, OAuth allow-lists stay valid, and the page origin is unchanged, so the remote DSH login state survives.
When the local side cannot take the same number, the rule is still built:
| Remote port | Windows | Linux | macOS |
|---|---|---|---|
| 82 | Same number (82:82) | Try 82:82, fall back to a high port | Skip, use a high port |
| 80 / 443 | Same as above | Same as above | Same as above |
| 3000 | 3000:3000 | 3000:3000 | 3000:3000 |
Low remote ports are not excluded: the forwarded connection starts from the remote loopback, so only the local listener is affected.
Never forwarded automatically: SSH itself (22 / 2222), the DSH Web port (3080), and addresses bound to a specific interface (192.168.1.5:8081) — not reachable from the remote loopback.
Manual rules, static rules, and cleanup
Under Settings → Forwarding rules you can write a rule by hand.
localhoston the remote side is fine.- Set the local port to
0and the system picks a free one. - Tick Static and the rule is never cleaned up automatically.
Cleanup behaves like this:
- When the remote port stops listening, the rule and its tab are removed — manual rules are checked too.
- It takes 3 rounds (about 6 seconds), so a brief restart does not count. Rules you created or edited get a 5-minute grace period, and a service that really comes back recovers in the same round after a removal.
Static rules and the built-in DSH entry are never removed.
HMR and the Host header
HTTP and WebSocket are just byte streams through a transparent TCP forward. The page loads from http://127.0.0.1:<local-port>, so the HMR client reconnects to the same port and hot reload works.
The one thing that needs handling is the Host header: your browser sends Host: 127.0.0.1:<local-port>, and a remote Vite dev server with an allowedHosts allow-list rejects it. Each rule can rewrite Host (origin / target / off / custom), and Origin too.
https targets are the exception: Host lives inside TLS and cannot be rewritten. The TLS stream is passed through and opened as https://127.0.0.1:<port> locally; certificate mismatches are tolerated only for loopback, since the traffic is already inside the tunnel. The remote side answers with its default vhost — fine when there is only one.
Pages that ask for a password
When the address needs authentication (Basic auth on a reverse proxy, a login wall in front of DSH), the app raises its own dialog instead of a bare 401: it names the address and realm, and Remember password stores the credential encrypted in the system key store.
One window, several tabs
The DSH home page is the base page: it cannot be closed and its address cannot be edited. Forwarded pages open as tabs with back / forward / reload and an http/https-only address bar; the tab bar appears only once a second page is open.
Where it stops
- Automatic forwarding needs the plugin. Without
dsh-devtools, or with aDSH_HOMEthat moved the snapshot, no automatic rule is created. Manual rules still work. - Only processes descending from DSH count. Services started with
nohup &, pm2, systemd, screen or tmux outside DSH, or ports published by a container, have no lineage and stay invisible — better to miss one than to forward someone else's service. Add a rule by hand. - Only your own processes are visible. Non-root
lsoflists sockets of the same user; if DSH runs in a container and you SSH into the host, ports are missed. - The local listener is bound to
127.0.0.1. Other machines on your LAN cannot reach it. - The SSH server must allow forwarding. With
AllowTcpForwarding nothe rule fails withadministratively prohibited. - Nothing is exposed to the internet. The plugin's remote-access page can do that, after an explicit risk confirmation.
FAQ
The plugin is installed but no rule appears.
Read the status line first: can it not read the snapshot, or did the plugin report ports that are not listening? Usually dsh was not restarted after install, or the service was started outside DSH.
Why is the local port not 3000?
The local number was taken, or the remote port is a low one such as 82 that macOS will not let a normal user bind. The rule is still built and the log says which port it fell back to.
Will my manual rule be removed?
It participates in the remote check. Tick Static to keep it; a newly created rule has a 5-minute grace period.
Does this work on a phone?
Yes, with the same rule. The mobile app needs a membership ($30 per year or $90 for a lifetime v1.x licence); the desktop app is free and needs no account.
Related reading
- The dsh-devtools plugin: a dev workbench inside your remote DSH — it writes the port snapshot
- DSH Remote vs VSCode Remote: two ways to work remotely — where this rule comes from
- What is DSH Remote? The four capabilities explained
- Docs: Live debugging: see it the moment you save · When it will not connect
- Download the client · Pricing and membership