How to self-host E2B: requirements, costs and managed options
E2B self host deployments use E2B Embed: the Apache-2.0 runtime packaged for one Linux machine with KVM. You can run it with Docker Compose, with Terraform on GCP, AWS or Azure, or on one node of a Kubernetes cluster. Choose it when you need E2B inside your own environment and your team can own the host, upgrades and recovery. E2B's Bring Your Own Cloud (BYOC) is a separate enterprise service that E2B operates for you.
If you need code execution and do not want to run that stack, we recommend Lizard (lizard.build). Start a Small interpreter sandbox with lizard sandbox create -t interpreter -s small --timeout 600000, then use CodeSandbox.connect(id) in Lizard SDK. Lizard Sandboxes use Firecracker microVMs, each with its own kernel. The code interpreter guide covers SDK setup. Self-hosting is the better fit when you must control the deployment boundary yourself.
Can you self-host E2B?
Yes. E2B's current self-hosting entry point is E2B Embed, which puts the runtime and its supporting services on one node. The old e2b-dev/infra address now redirects to e2b-dev/runtime, so older search results about "E2B infra" can point you to instructions written for a different repository layout.
E2B describes Embed as a way to ship sandboxes inside your own product or run them inside a customer's environment, for example in government or regulated industries where data has to stay in place. E2B's Embed guide says it uses the same SDK and API as E2B Cloud, so moving an existing application to Embed is a configuration change. Because it is a single node, one host failure stops the whole installation.
There are three deployment choices, and they differ in who operates them. Embed is software you operate. E2B Cloud is a managed service. BYOC runs in your cloud account, but E2B provisions, monitors and operates the cluster. The E2B enterprise page, checked November 9, 2026, lists BYOC on AWS, GCP and Azure and marks private cloud as in development.
The AWS sample repository is another route you may find in search. Its README describes a deployment layer built with CloudFormation and Nomad around a copied upstream revision. Those instructions belong to that sample; the Compose steps here follow E2B's current Embed package.
What does the self-hosted stack contain?
E2B's runtime architecture includes Firecracker, an API, an orchestrator, a sandbox traffic proxy, a dashboard and data stores. You operate all of them.
In the runtime architecture, the API handles sandbox lifecycle and placement. The orchestrator drives Firecracker on the execution node. Inside each guest, envd handles processes and filesystem operations. The client proxy routes application traffic into sandboxes, and the template builder prepares the images sandboxes start from.
E2B's Embed guide places the supporting services on the same machine. PostgreSQL stores control-plane data, Redis handles coordination and caching, and ClickHouse holds logs and metrics. Templates and snapshots also live on the local disk. Docker Compose runs the service stack, while sandbox execution still needs hardware virtualization.
Host RAM and disk must cover the supporting services and guests. A machine with 16 GiB of RAM cannot give all of it to sandboxes.
What infrastructure does it need?
For the documented x86-64 route, you need a Linux host that exposes KVM, enough memory for the stack and the guest reservation, and permission to change host configuration. A generic VM that runs Docker may still lack virtualization access.
E2B's official Compose requirements, checked November 9, 2026, specify:
| Requirement | Documented baseline |
|---|---|
| Recommended operating system | Ubuntu 24.04 |
| x86-64 host kernel | Linux 6.8 or newer |
| Host devices | /dev/kvm and /dev/net/tun |
| Service runtime | Docker Engine 27+, Compose 2.24+ |
| Recommended host memory | 12 GiB |
| Available disk space | 20 GiB |
| Default guest memory reservation | 2,048 hugepages of 2 MiB, totaling 4 GiB |
The Compose guide says the guides were written and tested on x86-64. The same two files also run on arm64, because the pinned images are published for both architectures, but arm64 needs Linux 6.10 or newer. On Ubuntu 24.04's stock 6.8 kernel, the arm64 stack reports healthy while every sandbox start fails until you install the linux-generic-hwe-24.04 kernel.
On a cloud VM, nested virtualization must be enabled on a machine family that supports it. Google's nested virtualization documentation explains how the host and guest relate. Check that the instance type supports it before you pick a cheaper machine.
The Embed repository has Terraform modules for GCP, AWS and Azure. The GCP module requires Terraform 1.7.5 or newer, cloud credentials, and the Compute Engine and Cloud Resource Manager APIs. It creates the host for you. If you already have a suitable Linux machine, you can skip Terraform and use Compose directly.
The GCP module defaults to n4-standard-4, with a 50 GB Hyperdisk Balanced boot disk and nested virtualization enabled. Its default zone is us-west1-b. The cost example below moves the host to Iowa so every price refers to one region.
How do you deploy it?
Deploy E2B Embed on a suitable Linux host by downloading its Compose package, starting the services and running the smoke test. These steps follow E2B's Compose guide. We did not run them: our research sandbox has no /dev/kvm, so we could read the configuration and check the arithmetic but could not start Firecracker guests.
1. Check the Linux host
On an existing host, check the devices and installed versions:
ls -l /dev/kvm /dev/net/tun
docker version
docker compose versionConfirm the other requirements in the Compose guide, including RAM, disk space, cgroup v2 and outbound access to the image and artifact registries. The setup changes host networking and kernel settings, so use a machine dedicated to this workload.
2. Download the Compose package
Download both files from the official package into a new working directory:
mkdir e2b && cd e2b
curl -fsSL --remote-name-all "https://raw.githubusercontent.com/e2b-dev/runtime/main/embed/compose/{compose.yaml,.env}"Review the files before you start them. For a repeatable installation, replace main in the URL with a reviewed commit SHA and keep both files from that revision. The .env file pins the component images; without it, Compose stops with interpolation errors.
3. Start services and run the smoke test
Start the services and wait for readiness:
docker compose up -d --waitAccording to the guide, the first start checks and prepares the host, downloads the artifacts and images, migrates the databases and builds the base template. A healthy API does not yet show that a sandbox can run code, so run the packaged smoke test next:
docker compose --profile test run --rm smokeThe test creates a sandbox, runs a command, reaches a port through the proxy and ends it. We did not run it here. E2B's Compose guide tests e2b@2.46.1 (JavaScript) and e2b==2.46.0 (Python). To point your own SDK at this installation, load its SDK variables, including the team API key the first start generated:
eval "$(docker compose exec ready cat /run/e2b/sdk.env)"Keep the key out of source control and logs.
4. Diagnose startup failures
If startup fails, start with docker compose logs preflight. A missing KVM device points to host virtualization. A failure at base-template means reading the orchestrator and API logs. For the Terraform route, use the module source from the repository: a copy of the GCP directory alone loses its references to the Compose files and fails at plan time.
How much does it cost to self-host E2B per month?
Using unrounded calculations from Google's published compute, disk and IPv4 rates, a single-node E2B Embed installation on GCP costs about $140.07 for 730 hours of base infrastructure in Iowa. This planning estimate covers one evaluation node, excludes high availability and has not been measured against a deployed bill.
All inputs were checked November 9, 2026. Currency is USD. The period is 730 running hours, the region is Iowa (us-central1) and the example zone is us-central1-a. Prices are Linux on-demand, with no committed-use or Spot discounts. Check machine availability and quota in your zone before provisioning.
Calculation inputs
| Input | Quantity and rate | Official source |
|---|---|---|
| Compute host | One n4-standard-4: 4 vCPU, 16 GiB; $0.1814/hour | Google general-purpose VM pricing, checked November 9, 2026 |
| Boot disk | 50 GiB Hyperdisk Balanced at $0.000109589 per GiB-hour, about $0.08 per GiB-month | Google disk pricing, checked November 9, 2026 |
| Extra disk performance | None above the included 3,000 IOPS and 140 MBps baseline | Google disk pricing, checked November 9, 2026 |
| External IPv4 | One address in use on a standard VM at $0.005/hour | Google network pricing, checked November 9, 2026 |
Calculated monthly amounts
| Component | Arithmetic | Estimate |
|---|---|---|
| Host | 730 × $0.1814 | $132.42 |
| Disk capacity | 50 × 730 × $0.000109589 | $4.00 |
| IPv4 | 730 × $0.005 | $3.65 |
| Base infrastructure | $132.422 + $4.000 + $3.650 | $140.07 |
The estimate assumes no separately billed network traffic and no extra logging volume. It leaves out backups, restore storage, extra disk performance, external monitoring, TLS infrastructure, taxes, paid support and engineer time. It also leaves out model inference and application hosting.
For a production budget, add your own traffic and storage, then price backups, recovery and the engineer hours you expect to spend on the host each month.
The host is billed for all 730 hours even when no sandbox runs. Its four vCPUs also serve the control plane and databases, so guests do not get four dedicated vCPUs. Measure your own workload before you estimate sandbox capacity or compare this with a managed bill. The sandbox pricing comparison shows workload-based calculations.
What do you have to maintain afterwards?
When you operate E2B Embed, you own host patching, component upgrades, capacity planning and recovery. The biggest risk in the default GCP module is data loss on replacement, because a replaced instance starts from a fresh disk.
The GCP guide, checked November 9, 2026, says the module has no persistent data disk. When auto-healing recreates the instance, it rebuilds base and the templates you built are gone. A healthy replacement can still be missing your custom templates. Before you rely on the deployment, decide what you must keep, set up backups and practice a restore.
Upgrades need a procedure too. Pin the module revision and component versions, review the changes, and test sandbox creation and proxy traffic after each upgrade. The GCP guide says terraform apply records a new instance template but does not replace the running instance, because the update policy is opportunistic. The guide's replacement command recreates the instance, which also wipes custom templates, so schedule it as downtime.
Capacity work covers guest hugepages, CPU contention and disk growth. E2B's Compose guide says the default 4 GiB reservation holds eight 512 MiB base sandboxes at full memory, or about twenty idle ones. Past that, the stack stays healthy but each new sandbox fails to start until you raise HUGEPAGES. The same guide says one node refuses its 201st running sandbox, and pausing needs disk space equal to the sandbox's memory. Alert on these limits as well as on request failures.
Patch the Linux host and supporting services, restrict network access, rotate installation secrets and protect the Terraform state. E2B's Compose guide warns that orchestrator port 5008 is an unauthenticated control API; keep it inaccessible to untrusted peers. The GCP guide explains that generated secrets live in the state and reach the instance through metadata. E2B's Embed limitations specify plain HTTP with no TLS of its own, so keep it inside a protected network and add encryption in front of it where you need it.
How do self-hosted E2B, E2B Cloud and Lizard Sandboxes compare?
Choose self-hosted E2B when running inside your own environment is a hard requirement. Choose E2B Cloud when you want to keep your E2B integration and hand off operations. Consider Lizard Sandboxes when you want managed Firecracker execution and can adopt Lizard SDK.
| Option | Who operates it? | Cost basis | Best fit and trade-off |
|---|---|---|---|
| Self-hosted E2B Embed | Your team | About $140.07/month base infrastructure in this example, plus operations and excluded services | Deployment control; single-node failure and recovery are yours |
| E2B Cloud | E2B | Pro: $150/month plus usage; 2 vCPU and 4 GiB cost $0.1656/hour from the published CPU and RAM rates | Existing E2B applications; official pricing, checked November 9, 2026 |
| Lizard Sandboxes | Lizard | Pro: $19/month including $19 of usage, then pay as you go; Small: 2 vCPU and 4 GB at $0.0162/hour, billed per second | Managed execution with Lizard SDK; pricing, checked November 9, 2026 |
The rows cover different service boundaries. The self-hosted price includes shared supporting services, while the managed rates are per sandbox. They do not give a savings ratio for the same workload.
Lizard Pro allows 40 running sandbox vCPU, which is 20 Small sandboxes, with unlimited starts. The limits documentation explains how vCPU is counted across an account. The smaller Mini size (1 vCPU, 2 GB, $0.0081/hour) also runs the interpreter template. Lizard CLI and Lizard SDK give a new sandbox five minutes unless you set a longer lifetime, for example with --timeout in the CLI. On the 7-day trial, each sandbox is deleted 1 hour after it starts at the latest. Longer lifetimes come with the first payment, and a paid sandbox stops after at most 596 hours.
Moving from E2B to Lizard means changing application code and testing it, since both use Firecracker but the SDKs differ. For E2B lifecycle and pricing details, read the E2B sandbox guide. The Lizard vs E2B comparison covers the managed choice.
FAQ
Can I self-host E2B with Docker Compose? Yes. Embed ships two files, compose.yaml and .env, that run the supporting services and the runtime. Sandbox execution still needs a Linux host with KVM.
Do I need Terraform to self-host E2B? No. You can run Compose on an existing suitable host. The official Terraform modules create the host for you on GCP, AWS or Azure.
Is E2B BYOC the same as self-hosting? No. BYOC puts the infrastructure in your cloud account, and E2B provisions, monitors and operates the cluster. With Embed, your team operates the installation.
Does E2B Embed provide a highly available cluster? No. Embed is a single-node package. The GCP module runs a managed instance group of one; auto-healing can recreate the instance, but it adds no second node and loses custom templates.
Can I run E2B Embed on a Mac? Only inside a Linux virtual machine. The Embed limitations require Apple silicon M3 or newer and macOS 15 or newer for that setup.
What should I test before connecting an agent? Run the packaged smoke test, then test your own templates, network restrictions and restore procedure. A passing API health check does not cover those.
Build with AI. Ship with Lizard
You don't need a platform team to go live. Your whole cloud, one CLI command away.
- Services
- —
- Add-ons
- —
- Deployments
- —
- Sandbox starts
- —