Skip to content

Lifecycle: timeout, pause, resume, kill

A miniVM is in one of three states: running, paused or killed. This page explains how it moves between them and what each state costs you.

State What it means What you pay
running The miniVM runs. You can run commands, read files and reach its ports. Compute, per second, on its vCPUs and memory.
paused Its memory and disk are saved. Nothing runs. It does not count as running. Storage only (see Pricing).
killed It is gone. Its disk, memory and snapshots are deleted. Nothing.

Every miniVM has a timeout: the time it may live before it ends. You set it when you create the miniVM, in seconds.

Terminal window
ons create --timeout 600
  • The default is 300 seconds (5 minutes). The longest is 86400 seconds (24 hours).
  • When the timeout ends, the miniVM is killed. Create it with --auto-pause to pause it instead.

To extend a running miniVM, set a new timeout from now:

Terminal window
ons resume --timeout 1800 <minivm-id>

<minivm-id> is the id ons create printed (ons ls lists yours). On a running miniVM, ons resume only moves its deadline; it does not restart it.

With the E2B SDK, use set_timeout (Python) or setTimeout (JavaScript). A timeout change on a paused miniVM is refused with 409: resume it first.

A pause saves the miniVM’s memory and disk. A resume brings it back with its files and running processes as they were.

Terminal window
ons pause <minivm-id>
ons resume <minivm-id>
  • ons resume restarts the timeout clock from now (300 seconds by default, or --timeout).
  • A second pause of a paused miniVM answers 409. A resume of a running miniVM only extends it.
  • With the E2B SDK, pause() pauses, and Sandbox.connect(<minivm-id>) resumes a paused miniVM (201) or connects to a running one (200).

You don’t always need ons resume. These wake a paused miniVM first, usually in about a second and at most 30 seconds:

  • ons exec, ons shell, ons push and ons proc on it.
  • A request through ons forward.
  • An SDK request to the miniVM’s envd (commands, files) with its access token.

If it cannot wake (for example, you reached your running limit), the error says so. Run ons resume <minivm-id>: it resumes the miniVM or names the limit in the way. Traffic wakes a paused miniVM at most 6 times a minute; past that, you get 429 until the minute ends. ons resume and connect are not limited this way.

Terminal window
ons create --auto-pause --timeout 3600

With --auto-pause (E2B: autoPause), the miniVM is paused instead of killed when its timeout ends. If the pause fails, or your organization already holds its maximum number of paused miniVMs (10 for a self-serve organization), it is killed, with end reason auto_pause_limit.

A running miniVM with no activity for a while is paused. By default, that is after 600 seconds (10 minutes) without activity.

Terminal window
ons create --auto-pause --auto-pause-idle 900
  • --auto-pause-idle (E2B extension: autoPauseIdle) sets the delay in seconds: 0 means never, otherwise 60 to 86400.
  • Activity is anything that uses the miniVM: commands, file calls, port traffic, egress, CPU use, open streams, and API calls that act on it (create, connect, timeout changes, pause, resume). Reading its details or listing it does not count.
  • An idle pause is skipped while your organization already has half of its paused limit in use (5 of 10 for a self-serve organization). The miniVM keeps running, and is billed, until its timeout. The other half is kept for pauses you ask for and pauses at the timeout. See Quotas and limits.
  • An idle pause never moves the timeout. A miniVM created without --auto-pause is still deleted at its timeout, even while paused for idleness.

GET /sandboxes/<minivm-id> gives a pauseReason while it is paused:

pauseReason Cause
api You paused it.
timeout Its timeout ended and it had auto-pause.
idle It was idle for its delay.
memory_pressure Its host was short of memory and it was among the least recently active.
maintenance Its host was emptied for a planned reboot. It is resumed on another host, with its end time kept.
hold Your organization is on hold (see below).
egress_unapplied A removal of egress names did not reach its host within 10 minutes. Its next resume applies the new list. See Egress.

A paused miniVM is kept for 30 days. After that, it is killed and its saved state is deleted. Resume it before then, or kill it yourself when you no longer need it.

A resume or a connect may answer 503 with a Retry-After header and a reason. Wait that many seconds, then retry. The E2B SDKs retry on their own.

reason Cause
cpu_saturated Every host that fits is short of CPU right now.
snapshot_unrestorable No host could restore the saved state yet (for example, after a host update). The miniVM stays paused; retry later.
minivm_moving The miniVM is still pausing or moving.
hybrid_runner_unknown On a Hybrid pool: the miniVM has no runner to reach it on yet.

When an AI account bound to the miniVM could not be renewed while it was paused, the miniVM still resumes, without that account. The resume or connect answer names it in msb.aiAccountsLost ([{"accountId", "reason"}]), and ons resume, ons forward and ons agent print a warning. Create a new miniVM to bind the account again.

A pause keeps the values of egress credentials, also when the miniVM resumes on another server: while it is paused, they are at rest only inside its encrypted pause snapshot. In some cases, such as a platform restart, they are not kept: a request to a host that uses one answers 503 msb_credential_unavailable until you send the values again, in egressCredentials of the resume or with PUT /sandboxes/<minivm-id>/egress-credentials.

At 0 credits, your organization is on hold:

  • New miniVMs, resumes, wake-ups, connecting to a paused miniVM, timeout extensions, template builds and new agent runs are refused with HTTP 402 organization_on_hold. ons and the console point you to the billing page.
  • Running miniVMs are paused, never killed. Their state is saved and kept like any paused miniVM (30 days).
  • A miniVM running a coding agent in the middle of a task gets up to 5 minutes, or until its next idle point, before it is paused. The balance may run down to −50 credits for this. Past that, the miniVM is paused at once.

When you add credit, the hold lifts within a minute. Resuming is up to you: nothing resumes on its own. See Billing.

While your organization has no payment method, the same calls are refused with 402 payment_method_required instead. You can still list, inspect, pause and kill miniVMs, and connect to a running one without a new timeout. See Billing.

Terminal window
ons kill <minivm-id>

Killing a miniVM stops it and deletes it: its processes stop, then its disk copy, snapshots, network state and limits are removed, and we record a deletion receipt listing each step (planned: the end-to-end test of this has not passed yet). The kill call returns once the receipt is stored (within 10 seconds).

  • With the E2B SDK, kill() returns true, and false on a miniVM already killed (404).
  • In the console, owners can kill any miniVM of the organization, and members the miniVMs of their own keys.

ons inspect <minivm-id> shows a miniVM, including why it ended once killed. Ended miniVMs are also listed by GET /v2/sandboxes?state=killed, each with endAt and endReason. The most common reasons:

endReason Cause
api You killed it with a key.
dashboard Someone killed it in the console.
timeout Its timeout ended without auto-pause.
paused_expired It stayed paused past its retention, or its timeout ended while it was idle-paused.
auto_pause_failed Its timeout ended and the pause failed.
auto_pause_limit Its timeout ended while the organization held its maximum number of paused miniVMs.
out_of_memory It ran out of memory on its host.
lost Its host became unreachable and it never came back (see below).
create_failed It never started: the create failed.
member_removed The member whose key created it left the organization.
organization_suspended, abuse Your organization was suspended, or the miniVM was stopped for abuse.

Rarely, a miniVM’s host becomes unreachable. Calls to that miniVM then answer 503 with “miniVM <id> is lost”. It may come back. If it does not, kill it. A miniVM lost while paused is resumed from its saved copy on another host.

If a host reboots without warning, the miniVMs running on it end. Paused miniVMs on it are kept, and you resume them with ons resume. A paused miniVM whose saved copy on that host did not survive the reboot resumes from the stored copy when there is one, and is killed otherwise.