Skip to main content

Expose Localhost via MorphVM (Reverse SSH)

Tunnel laptop localhost: to a MorphVM with ssh -R, then expose that VM port to get a public URL.

How it works

[Your laptop] localhost:8000 -> (ssh -R) -> [MorphVM] 0.0.0.0:8000 -> Expose HTTP Service -> public URL

Prerequisites

  • A running instance (e.g., morphvm_XXXX)
  • SSH key configured for your account
  • A local app listening on a port (examples use 8000)

1) Create the reverse tunnel (run on your laptop)

Use ssh -R to bind a port on your MorphVM that forwards to your laptop’s localhost:

ssh -N -R 0.0.0.0:8000:127.0.0.1:8000 morphvm_XXXX@ssh.cloud.morph.so

Optional resilient variant (reconnects automatically on flaky networks):

autossh -M 0 -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -N -R 0.0.0.0:8000:127.0.0.1:8000 morphvm_XXXX@ssh.cloud.morph.so

2) Publish that VM port as a URL

Expose the MorphVM port to the internet with an authenticated HTTP Service.

morphcloud instance expose-http morphvm_XXXX local-8000 8000 --auth-mode api_key

Note: When auth_mode=api_key, call the URL with Authorization: Bearer YOUR_API_KEY.

Tips

  • TTL pause drops the tunnel; enable Wake-on-SSH or Wake-on-HTTP.
  • Prefer 127.0.0.1 as the destination in -R for clarity and security.
  • Use api_key auth for webhooks and dev previews.

Troubleshooting

  • 502 or timeout: ensure your ssh -R or autossh process is running.
  • Port already in use: pick another remote port (e.g., 8001).
  • Paused VM: enable Wake-on-HTTP/SSH, then retry.

See also