Self-hosting E2B: run E2B code sandboxes on your own servers A developer documented a self-hosted deployment of E2B, the code-execution sandbox used by AI agents, using an open-source project called OpenDsec that runs Firecracker microVMs on a single Linux x86_64 machine. The quickstart script installs an E2B-compatible gateway on port 7400 with a Python 3.12 template, letting the standard E2B Python and JS/TS SDKs connect unchanged, and the setup took about 11 minutes on a fresh 8-core VM. The writeup also covers memory-preserving fork, snapshot and pause features for agent tree search and RL rollouts, plus building E2B's code interpreter from its open-source server. E2B https://e2b.dev is one of the most used code execution sandboxes for AI agents: the code an agent writes runs in an isolated Firecracker microVM, and many agent frameworks support E2B. But E2B is mainly a hosted cloud service, so your code and data go to E2B's cloud. When data must stay on your network, the network is air-gapped, or you run enough sandboxes that the hosted price stops making sense, you self-host. The short version. There are two ways to self-host E2B: This post walks through the second: a single-machine install, calling it with the E2B SDK, setting up the code interpreter, growing into a cluster, and how it differs from E2B. You need a Linux x86 64 machine tested on Ubuntu 24.04 with systemd and cgroup v2. For microVMs Firecracker, as in E2B you also need /dev/kvm : bare metal, or a cloud VM with nested virtualization. sudo -i the rest runs as root apt update && apt install -y make git python3-venv curl -fsSL https://go.dev/dl/go1.27.3.linux-amd64.tar.gz | tar -C /usr/local -xz git clone https://github.com/kernflux/opendsec && cd opendsec deploy/quickstart.sh The script builds the binaries, downloads Firecracker and the guest kernel, and installs every service, including the E2B gateway port 7400 with a template named base Python 3.12 . On a fresh 8-core VM the whole run took about 11 minutes, most of it building. The install writes /root/opendsec-ops/demo.env , which already holds the three variables the E2B SDK reads: . /root/opendsec-ops/demo.env sets E2B API URL, E2B SANDBOX URL, E2B API KEY python3 -m venv .venv && .venv/bin/pip install e2b E2B API KEY is the OpenDsec token written as e2b followed by its hex, the only form some versions of E2B's Python SDK 2.25 to 2.45 accept; the gateway decodes it back into the token. From here the code is exactly what you would write for E2B's cloud run it with .venv/bin/python : python from e2b import Sandbox sbx = Sandbox.create template "base" print sbx.commands.run "python3 -V" .stdout sbx.files.write "/tmp/a.txt", "hello" print sbx.files.read "/tmp/a.txt" sbx.kill To call it from another machine, point the three variables at this machine: export E2B API URL=http://