---
title: "Preview URLs for sandbox ports · Pethost"
description: "Any port of a Pethost sandbox gets an HTTPS address: public, or private behind a per-port token. A visit wakes a paused sandbox in about 0.2 s."
---

[Agent Sandboxes](https://pethost.dev/sandboxes/) A URL for every port

# An HTTPS address for every port

A dev server in a sandbox is a preview URL you can send. There is nothing to register and nothing to wait for, and a preview nobody looks at pauses at 30% of the price until the next visit wakes it.

A visit to port 3000’s HTTPS address wakes a paused sandbox in 0.2 s and its page appears; a private port answers 200 to a request with its token and 401 to one without.

## 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.

Python

CLI

```
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 token
```

## Public 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](https://pethost.dev/sandboxes/ssh/).

## 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](https://pethost.dev/sandboxes/auto-pause/).

## 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.

[Read the docs](https://pethost.dev/docs/sandboxes/ports-and-previews/)

## Questions

**Can I use my own domain for preview URLs?**

No: every address is under the name of the sandbox’s server.

**Do WebSockets work?**

Yes, on public ports from a browser, and on private ones from a program that sends the token.

**Does a visit wake a paused sandbox?**

Yes, in about 0.2 s. A stopped one answers 503 unless its lifecycle wakes it when stopped.

**How do I keep a port private?**

Leave it out of the public ports: every port is private unless listed, and a token from `create_link` opens it to a program.

## Related

- [A sandbox pauses: its memory moves to its server’s disk and its price drops to 30%; a request arrives and it wakes in 0.08 s with the same process still running. Pauses with its memory A paused sandbox keeps its memory and processes on its server at 30% of the price, and the next call wakes it in about 0.1 s, exactly where it was. How it works](https://pethost.dev/sandboxes/pause-resume/)
- [A program calls run_command and the test output streams back; it edits a file in place; it starts a dev server and the call answers once port 5173 listens. Commands, files and a terminal Run a command and wait for its port, stream its output, edit files by exact replacement, open a terminal in the browser: one API call each. How it works](https://pethost.dev/sandboxes/code-execution/)

## Give your agent a computer in 0.15 s

[Start the free trial](https://console.pethost.dev/welcome?kind=sandboxes)

Pethost · Stephan Gomer · NIP 1133096755

Pethost

- [Templates](https://pethost.dev/templates/)
- [About](https://pethost.dev/about/)
- [Docs](https://pethost.dev/docs/)
- [Blog](https://pethost.dev/blog/)
- [API](https://pethost.dev/docs/api/)
- [CLI](https://pethost.dev/docs/cli/)
- [Plugin](https://github.com/pethost-dev/plugin)
- [Terms](https://pethost.dev/terms/)
- [Privacy](https://pethost.dev/privacy/)
- [Refunds](https://pethost.dev/refunds/)
- [support@pethost.dev](mailto:support@pethost.dev)

Databases

- [Postgres](https://pethost.dev/postgres/)
- [Valkey](https://pethost.dev/valkey/)

Agent Sandboxes

- [Sandboxes](https://pethost.dev/sandboxes/)
- [Pricing](https://pethost.dev/sandboxes/#pricing)
- [Docs](https://pethost.dev/docs/sandboxes/)
- [API](https://pethost.dev/docs/sandboxes/api/)

Comparisons

- [Coolify vs Dokploy vs CapRover vs Dokku](https://pethost.dev/blog/coolify-vs-dokploy-vs-caprover-vs-dokku/)
- [Coolify Cloud vs Dokploy Cloud](https://pethost.dev/blog/coolify-cloud-vs-dokploy-cloud/)
- [Railway vs Render vs Fly.io pricing](https://pethost.dev/blog/railway-vs-render-vs-fly-io-pricing/)
- [Managed Docker Compose hosting](https://pethost.dev/blog/managed-docker-compose-hosting/)

Alternatives

- [Railway alternatives](https://pethost.dev/blog/railway-alternatives/)
- [Heroku alternatives](https://pethost.dev/blog/heroku-alternatives/)
- [Dokploy alternatives](https://pethost.dev/blog/dokploy-alternatives/)
- [Coolify alternatives](https://pethost.dev/blog/coolify-alternatives/)
- [Render alternatives](https://pethost.dev/blog/render-alternatives/)
- [Sliplane alternatives](https://pethost.dev/blog/sliplane-alternatives/)
