Synopsis
Description
Theport command group forwards ports from a running sandbox to your host so you can open http://localhost:<port>/ in a browser, point a database client at the sandbox, or hit an API running inside the guest — without leaving your terminal or writing Python.
Use it when you started a web server, dev server, or API inside a sandbox and want to reach it from your host machine.
Forwards are non-blocking and survive the CLI process exiting. They keep running until you call
smolvm port close, stop the sandbox, or reboot your host. Active forwards are tracked in ~/.smolvm/forwards/<sandbox>.json.Subcommands
All
port subcommands accept --comm-channel {ssh,vsock} to choose the host-to-guest control channel. Leave it unset for auto-selection. See control channel.expose
Forward a guest port to localhost.host-port:sandbox-port— bind a specific host port (for example8080:3000).sandbox-port— let SmolVM pick any free host port (for example3000).
Arguments
Name or ID of the running sandbox.
Port mapping in the form
host-port:sandbox-port or just sandbox-port to auto-select a host port.Options
Emit machine-readable JSON output.
SSH private key path for connecting to the sandbox.
SSH user to connect as.
Examples
Forward sandbox port 3000 to host port 8080:close
Remove a forwarded port.smolvm port list if you’ve forgotten the mapping.
Arguments
Name or ID of the sandbox.
Mapping to remove, in the form
host-port:sandbox-port.Options
Emit machine-readable JSON output.
SSH private key path for connecting to the sandbox.
SSH user to connect as.
Example
list
Show every active forward for a sandbox.Arguments
Name or ID of the sandbox.
Options
Emit machine-readable JSON output.
Example
Transports
TheTransport column shows how a forward is implemented:
nftables— kernel-level NAT, used when the host can route directly to the guest. Lowest overhead.ssh_tunnel— a background SSH tunnel, used when direct routing isn’t available (for example macOS hosts). Survives CLI exit and is cleaned up automatically byport close.
Exit codes
| Code | Description |
|---|---|
0 | Success |
1 | Error occurred (invalid mapping, sandbox unreachable, etc.) |
2 | Invalid usage (missing subcommand, malformed arguments) |
Common workflows
Preview a web app running in a sandbox
Connect a local client to a sandbox database
Tear everything down
Related
- Port forwarding — programmatic API from Python (
vm.expose_local()). smolvm ssh— connect to a sandbox shell.smolvm list— find sandbox names and IDs.
