Localhost Tunnel Notes

long-tail guide · niche cluster

SSH -L vs -R vs -D: Which Port Forward for Localhost APIs?

Most “API on the VPS but I develop on my Mac” bugs come from picking the wrong forward direction. Use this page as a decision card.

Quick decision

Local forward example

ssh -N -L 3000:127.0.0.1:3000 user@vps

Then open http://127.0.0.1:3000 on the Mac.

Remote forward example

ssh -N -R 9000:127.0.0.1:9000 user@vps

A process on the VPS talks to 127.0.0.1:9000, which lands on your Mac.

Security note

Prefer loopback binds on the VPS. Publishing 0.0.0.0:3000 “to skip the tunnel” is how CDP and admin APIs get scanned.