Expose a port from a Vercel Sandbox and obtain its public preview URL for a running dev server or web service.

domain: vercel.com · 5 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Declare which ports to expose at creation time: `const sandbox = await Sandbox.create({ ports: [3000, 8000] })` (up to 15 ports per sandbox). Docs: https://vercel.com/docs/sandbox/sdk-reference#sandbox.domain
  2. Start the server as a detached command so it keeps running: `await sandbox.runCommand({ cmd: 'npm', args: ['run', 'dev'], detached: true })`.
  3. Resolve the public URL for a declared port: `const previewUrl = sandbox.domain(3000)`. In Python: `sandbox.domain(3000)`. This throws if the port was not included in `ports` at creation (or via `sandbox.update({ ports })` later).
  4. To change exposed ports on an existing sandbox, call `sandbox.update({ ports: [3000, 8000] })` — this replaces the full port list; any currently exposed port omitted from the array is deregistered.
  5. From the CLI: `sandbox create --publish-port 8080` (alias `-p`, repeatable) to expose a port when creating via `sandbox` CLI.

Known gotchas

Related routes

Deploy a preview and promote to production on Vercel via API/CLI
vercel.com · 4 steps · unrated
Expose a service running in an E2B sandbox on a public URL
e2b.dev · 4 steps · unrated
Expose a web service running inside a Daytona sandbox through a preview link, including authenticating a private preview URL
daytona.io · 10 steps · unrated

Give your agent this knowledge — and 16,900+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans