Skip to content
Runtime

How to wake a sandbox on request

Do nothing: a paused sandbox wakes by itself when an exec, file, process or terminal call, or a visit to a shared port, reaches it.

On Runtime, automatic wake is on for every sandbox. The request that wakes it waits and then runs. The sandbox returns on the same host with its memory and processes. The wake is billed from the moment it runs again. Between requests, a paused sandbox costs $0.08 per decimal GB of saved state a month, and no compute (pricing, checked 26 October 2026).

Use it and it wakes

TypeScriptimport { Sandbox } from "withruntime";const sbx = await Sandbox.create({ timeoutSeconds: 900 });await sbx.exec("echo warm > /workspace/cache.txt");await sbx.pause();// Hours later, from any process. No wake() call is needed:const again = await Sandbox.connect(sbx.id);const hit = await again.exec("cat /workspace/cache.txt"); // waits for the wake, then runsconsole.log(hit.stdout, again.state);
Pythonfrom withruntime import Sandboxsbx = Sandbox.create(timeout_seconds=900)sbx.exec("echo warm > /workspace/cache.txt")sbx.pause()again = Sandbox.connect(sbx.id)hit = again.exec("cat /workspace/cache.txt")  # waits for the wake, then runsprint(hit.stdout)
Terminalruntime sandboxes exec "${id}" -- cat /workspace/cache.txt   # wakes a paused sandbox first

A web app that wakes on its first visitor

Share a port and let the sandbox pause. The next visit wakes it. An API client's request waits up to 30 seconds for the wake. A browser sees a short "Waking up" page that reloads itself. The preview is private, so share the link that carries its token. visibility: "public" gives an address with no token, on a paid sandbox only.

TypeScriptimport { Sandbox } from "withruntime";const app = await Sandbox.getOrCreate("demo-app", { idlePauseSeconds: 600 });await app.spawn("python3 -m http.server 3000");const preview = await app.previews.create(3000);console.log("share this:", preview.urlWithToken); // for a day, whether it runs or sleeps
Pythonfrom withruntime import Sandboxapp = Sandbox.get_or_create("demo-app", idle_pause_seconds=600)app.spawn("python3 -m http.server 3000")preview = app.previews.create(3000)print("share this:", preview["urlWithToken"])

What wakes a paused sandbox

Request Wakes it How the caller sees it
exec, spawn, a process read or write Yes The call waits while it wakes, then runs
A file read, write or list Yes Same
A terminal, the desktop, the code interpreter Yes Same
An API client at a shared port Yes The request waits up to 30 seconds
A browser at a shared port Yes A "Waking up" page that reloads itself
Reading a file watch No Delivery stops with paused, and resumes after a wake
Any of these with autoWake: false No Fails with sandbox_paused until you call wake()

Each wake is an ordinary wake. The sandbox runs again. If it has a time limit, it gets a fresh limit of its own, timeoutSeconds. Billing starts when it runs.

Turn it off

For a sandbox that must stay paused until you decide, turn automatic wake off when you create it, or later:

TypeScriptimport { Sandbox } from "withruntime";const sbx = await Sandbox.create({ autoWake: false });await sbx.update({ autoWake: true }); // and back on
Pythonfrom withruntime import Sandboxsbx = Sandbox.create(auto_wake=False)sbx.update(auto_wake=True)  # and back on
Terminalruntime sandboxes create --no-auto-wakeruntime sandboxes update "${id}" --auto-wake off

Mistakes to avoid

  • Calling wake() before every request. It is not needed. A request wakes the sandbox and then runs. Call wake() only to choose a new timeoutSeconds, or to warm the sandbox before traffic arrives.
  • Treating sandbox_paused as a crash. It means autoWake is off. Call wake(), or turn automatic wake back on.
  • Ignoring a refused wake. A wake that cannot be paid for fails with the refusal, such as insufficient_funds. The sandbox stays paused with its data kept. A full host can also refuse a wake. No compute is charged for the failed attempt.
  • Expecting a fresh machine. A wake restores the same sandbox on the same host. A wake never swaps in a fresh boot. If memory images are missing, the wake is refused.

Facts on this page were checked on 26 October 2026.

100 free hoursin your first 30 days.

of a 1 GB machine

  • No credit card
  • Four sandboxes at once, 2 vCPU and 4 GiB each
  • Then prepaid credit from $10, no plan fee
Start free, no card
Start free, no card