Remote access for local development #

Last updated March 16, 2026
macos

Suppose you are developing a web app on your laptop and you want your phone to test it. Getting your phone to talk to the local webserver can be tricky depending on the local network environment. Instead use an SSH tunnel to expose a single port of your laptop as a port on a remote webserver. This is called an SSH tunnel. Assuming you already have ssh locally and a linux remote webserver.

Check the /etc/ssh/sshd_config file on your server has these turned on

AllowTcpForwarding yes
GatewayPorts yes

and restart the ssh server if necessary with sudo systemctl restart ssh.

Then on your local computer set up the tunnel with

ssh -R <remoteport>:localhost:<localport> username@server.com

For example:

ssh -R 6000:localhost:4000 me@example.com

The local webserver is on 4000. Connect to it from http://example.com:6000/.

If you are using vite you access may be blocked for security reasons. Turn on allowed hosts in your vite config file.

  server: {
    allowedHosts:['josh.earth']
  }