VS Code Remote-SSH: Forward a Localhost API Port
If you already use VS Code Remote-SSH, built-in port forwarding can replace a one-off ssh -L for day-to-day API calls.
Steps
- Connect to the VPS with Remote-SSH.
- Open the Ports tab.
- Forward the remote port (e.g. 3000) to a local port.
- Set visibility to localhost-only on your Mac.
- Call
http://127.0.0.1:3000from local terminals or browsers.
When to prefer raw SSH
Scripts, CI, or non-VS Code editors: keep ssh -L / autossh. VS Code forwarding is convenience, not a security boundary by itself — the VPS service should still bind to 127.0.0.1.