Open a remote Mac's dev server on your laptop's localhost
The dev server listens on the remote Mac's localhost, which your laptop cannot reach. Forward the port over ssh with ssh -N -L 5173:localhost:5173 me@work-mac.local and open http://localhost:5173; each -L forwards one port. hivemux connect forwards every dev server port started in the remote tmux while connected, and Option+W lists them.
A common setup: Claude Code runs on a desktop Mac, you work on it over ssh from a laptop, and Claude starts npm run dev. The terminal says Local: http://localhost:5173/, but opening that address on the laptop gives “This site can’t be reached”. Here localhost means the desktop Mac, not the laptop, and dev servers usually listen only there. The fix is to carry the port across the ssh connection.
Step 1. Find the port on the remote Mac
The dev server prints its address when it starts. If the output has scrolled away, list the listening TCP ports on the remote Mac:
lsof -nP -iTCP -sTCP:LISTENTypical defaults are 5173 for Vite and 3000 for Next.js.
Step 2. Forward it with ssh -L
On the laptop, open a second connection that only forwards the port:
ssh -N -L 5173:localhost:5173 me@work-mac.local-L port:host:hostport listens on the given port on your laptop and connects to host:hostport from the remote side, so localhost here means the remote Mac. -N runs no remote command, which is what you want for a connection that only forwards. Leave it running and open http://localhost:5173 in the laptop’s browser.
Each -L forwards one port. A frontend and an API need two:
ssh -N -L 5173:localhost:5173 -L 3000:localhost:3000 me@work-mac.localIf you always use the same ports, put them in ~/.ssh/config with LocalForward so every connection to that host forwards them:
Host work-mac HostName work-mac.local User me LocalForward 5173 localhost:5173 LocalForward 3000 localhost:3000Keep the local port the same as the remote one when you can. OAuth callback URLs, cookies and CORS settings usually name localhost:5173, and a different local port breaks them.
Step 3. Or let hivemux connect forward them
The manual method has two gaps: you have to know the port before Claude picks it, and a new server means a new -L. hivemux handles this as part of attaching to the other computer, a Mac or a Linux dev server.
hivemux is a tmux sidebar that shows every Claude Code session — running, waiting for you, or done — and lets you jump to the one that needs you. Install it on both computers:
curl -fsSL https://hivemux.dev/install.sh | bash# or, on a Mac: brew install hivemux/tap/hivemuxhivemux setupOn a Mac you connect to, turn on System Settings → General → Sharing → Remote Login; on a Linux server, run an ssh server (openssh-server or openssh). Then, from the laptop:
hivemux connect --add me@work-mac.local # check and remember the host oncehivemux connect me@work-mac.localWhile connected, hivemux checks every few seconds which TCP ports (1024 and up) are listened on by processes started inside the remote computer’s tmux, whether Claude or you started them, and forwards each to the same port on the laptop’s localhost. On a Linux server without lsof it reads them with ss and /proc, and a server that systemd took over in the background is still found. If that port is already taken on the laptop, the next free one is used. When the server stops or you close the window, the forward goes away.
Option+W (or right-click → Ports) lists the forwarded ports on either side. Enter opens the selected one in the browser of the computer you connect from, and Ctrl+Y copies its address. hivemux connect --ports prints the same list in a terminal.

To connect without forwarding, set HIVEMUX_PORTS=0:
HIVEMUX_PORTS=0 hivemux connect me@work-mac.localComparison
| Method | Which ports | Local port already taken | Lasts |
|---|---|---|---|
ssh -N -L |
One per -L, chosen in advance |
That forward fails; choose another local port | While that ssh runs |
LocalForward in ~/.ssh/config |
A fixed list per host | Same as -L |
Every ssh connection to the host |
| VS Code Remote-SSH, Ports view | Ones you add with Forward a Port | VS Code may map it to another local port | The VS Code session |
Dev server on 0.0.0.0 |
Every port, at the remote Mac’s address | Not applicable | Until the server stops |
hivemux connect |
Every port listened on in the remote tmux | Next free port | While connected |
The alternative: listen on all interfaces
You can skip forwarding by making the dev server listen on every network interface and opening http://work-mac.local:5173 from the laptop. Vite does this with npm run dev -- --host; Next.js next dev already listens on 0.0.0.0 by default.
This works, but anyone on the same network can open the server as well. On café, hotel or office Wi-Fi that means a development build, often with debug pages, source maps and no sign-in, reachable by strangers over plain HTTP. ssh forwarding keeps the server on the remote Mac’s localhost and sends the traffic through the encrypted ssh connection, so only you reach it. On a network you do not trust, prefer forwarding, and restrict Next.js with next dev -H localhost.
For the full remote setup (reconnects, notifications, mosh), see Work from another computer. Related: How to continue Claude Code from your phone or another computer and pasting images into Claude Code over ssh.
FAQ
What if the port is already in use on my laptop?
With ssh -L, pick another local port, for example -L 5174:localhost:5173, and open http://localhost:5174. hivemux connect does this by itself, trying the next free port up to 19 above the original; Option+W shows which local port each server got.
Does hivemux port forwarding work when I connect over mosh?
Yes. The forwards ride on a separate ssh connection that hivemux opens next to the session, so they work whether the screen is attached over ssh or mosh. That connection logs in with a key, which hivemux connect --add sets up.
Vite only listens on localhost. Is that a problem?
No. With ssh forwarding the remote Mac itself connects to localhost:5173, so a server bound only to localhost is reached as usual. You do not need --host for this.
Why is one of my servers missing from the Option+W list?
hivemux forwards TCP ports 1024 and up that are listened on by processes started inside the remote Mac's tmux. A server started from another terminal app or as a background service is not included; forward it with ssh -L.
How do I turn hivemux port forwarding off?
Connect with HIVEMUX_PORTS=0 hivemux connect me@work-mac.local. The session works as before, without forwarding any ports.