Skip to content

Port Forwarding

MoltShell lets you access web applications running on your VM through the browser. When you start a dev server on any port, you can preview it using the built-in port forwarding feature.

How it works

The terminal server on your VM includes a reverse proxy at /preview/:port/. When you add a port to the preview links panel, requests to that URL are forwarded to localhost:<port> on your VM.

The proxy path is:

Browser --> Cloudflare Worker --> VM nginx --> terminal server --> localhost:<port>

Using port forwarding

  1. Start a web server on your VM. For example:

    bash
    npx vite          # starts on port 5173
    python3 -m http.server 8080
    node server.js    # starts on whatever port your app uses
  2. Click the Links button in the terminal header bar (top right). This opens the preview links panel.

  3. Enter the port number in the input field and click Add.

  4. The panel shows the forwarded URL. Click the external link icon to open it in a new tab, or click the copy icon to copy the URL to your clipboard.

Port restrictions

For security, the following ports are blocked:

  • Ports below 1024 -- privileged system ports
  • Port 3001 -- reserved for the terminal server itself

All other ports from 1024 to 65535 are available for forwarding.

Each forwarded port appears as a row in the preview links panel. You can:

  • Open in new tab -- click the external link icon
  • Copy URL -- click the copy icon
  • Remove -- click the X icon to remove the port from your list

The preview links panel is collapsible. Click the Links button again to hide it.

Notes

  • Port forwarding only works while your VM is running. If the VM suspends, forwarded links will stop working until you resume it.
  • The forwarded URLs are accessible without additional authentication for preview convenience.
  • If your dev server binds to 127.0.0.1 (localhost), it will work. If it binds to 0.0.0.0, it will also work. The proxy connects to localhost on the VM.

MoltShell - Your Linux VM in the browser.