Sandbox Timeouts[src]

Sandboxes created by Deno Sandbox are intentionally ephemeral. They boot in milliseconds, serve their purpose, and disappear—reducing the blast radius of untrusted code and removing infrastructure chores. Still, you can control exactly how long a sandbox stays alive and even reconnect later when debugging is required.

Default timeout: "session"

JavaScript
await using sandbox = await Sandbox.create();
Python
from deno_sandbox import DenoDeploy

sdk = DenoDeploy()

with sdk.sandbox.create() as sandbox:
  print(f"Sandbox {sandbox.id} is ready.")
Python (Async)
from deno_sandbox import AsyncDenoDeploy

sdk = AsyncDenoDeploy()

async with sdk.sandbox.create() as sandbox:
  print(f"Sandbox {sandbox.id} is ready.")

With no options set, the sandbox lives for the duration of your script. Once the sandbox instance is closed, the microVM shuts down and frees all resources. This keeps costs predictable and prevents orphaned infrastructure.

Duration-based timeouts

Provide a duration string to keep a sandbox alive after the client disconnects:

JavaScript
const sandbox = await Sandbox.create({ timeout: "5m" });
const id = sandbox.id;
await sandbox.close(); // process can exit now

// later
const reconnected = await Sandbox.connect({ id });
Python
sdk = DenoDeploy()

with sdk.sandbox.create(timeout="5m") as sandbox:
  sandbox_id = sandbox.id
  sandbox.close()  # process can exit now

# later
with sdk.sandbox.connect(sandbox_id) as reconnected:
  print(f"Reconnected to {reconnected.id}")
Python (Async)
sdk = AsyncDenoDeploy()

async with sdk.sandbox.create(timeout="5m") as sandbox:
  sandbox_id = sandbox.id
  await sandbox.close()  # process can exit now

# later
async with sdk.sandbox.connect(sandbox_id) as reconnected:
  print(f"Reconnected to {reconnected.id}")

Supported suffixes: s (seconds) and m (minutes). Examples: "30s", "5m", "90s". Use this mode for manual inspection, SSH debugging, or when a bot needs to resume work mid-way.

If you require a longer timeout, it is possible to promote a duration-based sandbox to a Deno Deploy app using sandbox.deno.deploy().

Forcefully ending a sandbox

  • await sandbox.kill() immediately stops the VM and releases the lifetime if you need to tear it down before it would naturally expire.

  • Killing a sandbox invalidates exposed HTTP URLs, SSH sessions, and any attached volumes, but this also happens automatically when your code drops the last reference to the sandbox or the configured duration elapses.

Extending the timeout of a sandbox

Add more time to a running sandbox without interrupting ongoing processes.

JavaScript
const newTimeout = await sandbox.extendTimeout("30m");
console.log(`Sandbox now expires at ${newTimeout}`);
CLI
deno sandbox extend sbx_ord_abc123def456 30m

All active connections and processes continue uninterrupted while the sandbox's expiration time is updated.

  • Sandbox.create() – pass the timeout option when provisioning.

  • Sandbox.connect({ id }) – resume control of a duration-based sandbox.

  • Sandbox.kill() – terminate early.

  • Expose HTTP and SSH – note that their URLs/credentials die with the sandbox lifetime.

Last updated 2026-02-02 denoland/docs#9e5dd8d