The address
Every port of a sandbox has an HTTPS address of its own, https://<port>-<sandbox id>.<server>: for example https://3000-k3x9q2m7v1c8p4ra.sbx1.sandboxes.pethost.network. Each server has one wildcard DNS record and a certificate for every name under it, so a new sandbox needs no record of its own, and its addresses work as soon as it starts.
The server passes each request to what listens on that port inside the sandbox, on localhost too, so a dev server needs no --host 0.0.0.0. HTTP/1.1 and HTTP/2 both work, WebSockets included, and a sandbox’s ports serve up to 896 requests at once. A dev server that checks the Host header, as Vite’s does, needs the preview’s host in its allowed hosts.
from pethost.sandboxes import Ingress, PublicPort, Sandboxes, SandboxSettings
sandboxes = Sandboxes() # reads PETHOST_TOKEN
box = sandboxes.create_sandbox(settings=SandboxSettings(
ingress=Ingress(public_ports=[PublicPort(port=3000)])))
sandboxes.run_command(box.sandbox_id, command="python3 -m http.server 3000",
wait_for_port=3000)
print(sandboxes.get_sandbox(box.sandbox_id).settings.ingress.public_ports[0].url)
# https://3000-k3x9q2m7v1c8p4ra.sbx1.sandboxes.pethost.network
private = sandboxes.create_link(box.sandbox_id, port=8080) # a private port
print(private.url, private.token) # a request sends Pethost-Token: <token>pethost sandbox new --name web --public-port 3000
pethost sandbox run web --wait-for-port 3000 -d -- python3 -m http.server 3000
pethost sandbox url web 3000
pethost sandbox url web 8080 --token # a private port, and its tokenPublic or private
A port listed in the sandbox’s ingress settings is public: anyone with the address opens it. A sandbox lists up to 20, at its create or later, and none by default.
Every other port is private. It answers only a request that carries Pethost-Token: <token>, with a token that create_link makes for that one port, valid for an hour by default and a day at most. The server checks it before anything wakes and takes the header off, so your program never sees it; a request without it gets 401. A page of any origin may call the port with its token, since the server answers CORS for it, so your product’s frontend can talk to a user’s sandbox without making a port public.
A browser tab, a WebSocket or an image sends no such header. What a person opens in a browser is a public port, or a private one forwarded to their computer with ssh -L.
Preview URLs that sleep
A preview for each of your users is a few calls: a template with the project and its dependencies installed, a sandbox from it, the dev server started by run_command with wait_for_port, its port public, and a short pause timer. When nobody looks, the sandbox pauses with its memory, the dev server in it, at $0.0054 an hour for SMALL instead of $0.018. The next visit wakes it in about 0.2 s, and the server answers where it left off. A paused sandbox keeps its place on its server, so a wake is never refused for room.
A STOPPED sandbox answers its ports 503, “stopped: resume it”, unless its lifecycle says wake_when_stopped. Then a visit starts it, and its vCPUs count against your plan while it is stopped. When a sandbox pauses and stops.
Limits and prices
No custom domain: addresses are under the sandbox’s server. Up to 20 public ports. Ports carry HTTP and WebSockets; a raw TCP port, such as a database’s, is reached with ssh -L. Every sandbox’s address is under one domain, so the server takes the Domain off any cookie an answer sets: give your app’s cookies the __Host- prefix. Requests to each port show in the sandbox’s events, a line a minute with the requests, 5xx answers and bytes. A port has no price of its own: requests keep the sandbox awake, billed by the second at its size’s price, and idle it pauses.
How it compares
On 21 November 2026, boat.dev gave a port a URL with a token in it by default, up to 50 ports, and Vercel Sandbox opened up to 15 ports. Neither paused a preview with its memory: boat.dev has no pause, and a stopped Vercel sandbox kept its filesystem only. A paused Pethost preview answers its next visitor with the dev server as it was.