Documentation Index
Fetch the complete documentation index at: https://docs.celesto.ai/llms.txt
Use this file to discover all available pages before exploring further.
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:
from smolvm import SmolVM
with SmolVM() as vm:
vm.run("python3 -m http.server 8000 &")
host_port = vm.expose_local(guest_port=8000, host_port=8000)
print(f"Service available at http://127.0.0.1:{host_port}/")
Omit host_port to let SmolVM pick an available port automatically:
host_port = vm.expose_local(guest_port=8080)
print(f"Guest port 8080 exposed on localhost:{host_port}")
Multiple ports
Expose multiple services from the same sandbox:
with SmolVM() as vm:
vm.run("python3 -m http.server 8000 &")
vm.run("python3 -m http.server 9000 &")
port1 = vm.expose_local(guest_port=8000, host_port=8000)
port2 = vm.expose_local(guest_port=9000, host_port=9000)
print(f"Service 1: http://127.0.0.1:{port1}/")
print(f"Service 2: http://127.0.0.1:{port2}/")
Remove a port forward
Port forwards are automatically cleaned up when the sandbox stops. To remove one manually:
vm.unexpose_local(host_port=8080, guest_port=8080)
expose_local() only binds to 127.0.0.1 (localhost). Services are not exposed to your network.