Skip to main content
When keepAlive is enabled, the box stays on between sessions instead of auto-pausing when idle. Use it when you need a box to remain continuously available, for example to host a server, keep a long-running agent ready, or preserve an always-on development environment. For most workloads, the default Box lifecycle is still the better choice. Boxes auto-pause when idle and are more cost-efficient for bursty workloads unless keepAlive is enabled.

Create a keep-alive box

Use keepAlive: true when creating the box:
import { Box } from "@upstash/box"

const box = await Box.create({
  runtime: "node",
  size: "medium",
  keepAlive: true,
})
You can combine keep-alive with all normal Box features, including agent, git, shell, filesystem, previews, and snapshots.

Sizes and specs

Boxes with keepAlive enabled use the same Box sizes as any other box. Pick the size with the size option when creating the box or in the Console during box creation.
SizeCPUMemoryStorage
small2 vCPU4 GB5 GB
medium4 vCPU8 GB10 GB
large8 vCPU16 GB20 GB
The selected size determines the box’s available CPU, RAM, and workspace storage whether keepAlive is enabled or not.

Lifecycle differences

Default behaviorWith keepAlive: true
Idle behaviorAuto-pauses when idleStays on
Pause / resumeSupportedNot supported
Best forBursty workloads, task runners, on-demand agentsAlways-on servers, long-running agents, warm environments
Billing modelActive usage basedOpen-time / always-on based
If you do not need the box to remain continuously available, keep keepAlive disabled.

Init command

Boxes with keepAlive enabled can run a startup command whenever the box starts.
const box = await Box.create({
  runtime: "node",
  keepAlive: true,
  initCommand: "npm install && npm run dev",
})
This is useful for:
  • starting a web server
  • launching a background process
  • preparing a long-running agent environment
  • restoring a development workflow automatically after the box starts
You can also manage the init command after creation:
await box.setInitCommand("npm run dev")

const command = await box.getInitCommand()
await box.deleteInitCommand()

console.log(box.keepAlive) // true
Init command management is only available when keepAlive is enabled.

Console

In the Upstash Console you can:
  • enable Keep alive while creating a box
  • choose the box Size
  • manage the Init Command later from the box settings page

When to use keep alive

Use keep-alive when the box itself needs to stay available between requests:
  • hosting a dev server or preview app
  • keeping an agent warm for low-latency use
  • preserving a long-running environment with startup automation
Avoid keep-alive when you only need a reusable workspace. In those cases, the default box lifecycle plus Snapshots is usually enough.