Skip to main content
When you run a web server, database, or API inside a sandbox, port forwarding lets you access it from your host machine as if it were running locally.

Expose a port

Start a service inside the sandbox and expose it to your host:
Omit host_port to let SmolVM pick an available port automatically:
QEMU keeps expose_local() available when outbound access is off or restricted. On the default slirp network it uses QEMU forwarding; on Linux TAP it uses localhost forwarding to the guest IP. Ordinary HTTP, WebSocket, and file-transfer traffic does not require SSH or a guest agent. Have the application listen on 0.0.0.0 inside the sandbox. If it listens only on the guest’s 127.0.0.1, pass guest_loopback=True; this option requires guest SSH because it uses an SSH tunnel.

Multiple ports

Expose multiple services from the same sandbox:

Remove a port forward

Port forwards are automatically cleaned up when the sandbox stops. To remove one manually:
expose_local() only binds to 127.0.0.1 (localhost). Services are not exposed to your network.

From the CLI

If you already have a running sandbox, you can forward ports from your terminal — no Python required:
CLI forwards are non-blocking and persist after the command exits. See smolvm sandbox port for the full reference.
Last modified on September 10, 2026