Hetzner

Run your agents on a real, inexpensive Hetzner VPS with full root and Docker-in-Docker

Run your agents on a real, inexpensive cloud VM you fully control — no local Docker needed. Each box is its own Hetzner Cloud VPS (1:1) you drive with the same agentbox commands as a local box, reached over pure OpenSSH (no third-party agent in the box — you own root). Heads up: a Hetzner box is a real VPS that bills ~€4/mo even when stopped — pause is poweroff/poweron, not free — and its firewall locks to your current egress IP.

Switch per box with --provider hetzner, or pin it project-wide with box.provider: hetzner in agentbox.yaml. Pick Hetzner for bare-VPS control (full kernel, your own region), a Cloud Firewall locked to your egress IP, and full Docker-in-Docker. Cost is roughly €4/mo per running box. Comparing options? See local-docker, daytona, vercel, and e2b.

Set up

The easiest path is the interactive wizard — it signs you in and bakes the base snapshot in one flow:

agentbox install        # then select hetzner

Paste a Hetzner Cloud API token when prompted — a Read & Write token from the target project's Security → API Tokens page (boxes will be created in whichever project minted it). Credentials persist to ~/.agentbox/secrets.env; project .env files are never harvested. install also bakes the base snapshot (a one-time agentbox prepare --provider hetzner under the hood) with the AgentBox runtime — agentbox-ctl, tmux, the browser stack — so every new box boots ready in ~15-20s. Agents are a separate, optional tier on top (see below).

For CI or scripted setup, run the explicit equivalents:

agentbox hetzner login                 # credentials only
agentbox prepare --provider hetzner    # bake the base snapshot

NOTE

Mint the token under the specific Hetzner project you want boxes to live in, and make it Read & Write. Read-only tokens can't create servers.

Mint a Read & Write API token under Security → API Tokens in the Hetzner console.

Use it

agentbox hetzner claude

agentbox hetzner create|claude|codex|opencode|pi is sugar for the same command with --provider hetzner.

Prepare snapshot

Hetzner can't build an image from a Dockerfile, so a one-time base snapshot must be baked before the first create. agentbox prepare --provider hetzner boots a throwaway VPS, runs the install script, snapshots the result, then cleans up.

agentbox prepare --provider hetzner

The snapshot is a shell mirror of the Docker box image (Node, Python, Docker, the VNC stack, Google Chrome, and the agentbox-ctl supervisor). First run takes ~6 minutes; after that, every create --provider hetzner boots from it in ~15–20s. Re-running is idempotent — pass --force to rebake.

The base carries no agent. Add one as its own snapshot, on top of the base:

agentbox prepare --provider hetzner --agents claude

That boots the base, runs just Claude Code's install recipe and re-snapshots (~3–4 min). agentbox claude --provider hetzner then boots that snapshot with the agent already in place. Each agent set gets its own record, so baking --agents codex later does not invalidate the claude one, and each rebake deletes only the snapshot it replaces.

Skipping this is fine: a box whose agent isn't baked installs it on first use (~30–60s), and the result is identical — the bake and the on-demand install run the same recipe. It just moves that minute from bake time to every box's create.

When you upgrade AgentBox, create --provider hetzner notices if the new install would bake a different snapshot (the comparison is checksum-based on the baked files — CLI version strings on their own don't count) and offers to rebake inline; with -y or non-TTY it instead warns loudly and boots on the existing snapshot. agentbox hetzner login also nudges you toward agentbox prepare --provider hetzner on the first successful login.

Every bake pins box.imageHetzner to the new base's name. A bake on another machine (a control box's hub) replaces the base without re-pinning this machine's config, so the pin can name a snapshot that is gone. create then boots the current prepared base and warns that the pin is stale; clear it with agentbox config unset box.imageHetzner --global (or --project). If the prepared base itself was deleted, create names it and asks you to run agentbox prepare --provider hetzner. An image ref that is neither one of your snapshots nor a Hetzner image fails naming the ref.

If the bake fails installing Claude Code

The bake installs Claude Code with Anthropic's native installer, whose CDN occasionally returns a Cloudflare 403 to cloud-datacenter egress IPs (Hetzner among them). The bake retries three times and then aborts rather than shipping a Claude-less snapshot. If it keeps failing, switch to the npm installer:

agentbox prepare --provider hetzner --agent-setting claude.install=npm
# or persist it: agentbox config set claude.install npm

npm installs @anthropic-ai/claude-code and symlinks it into the same ~/.local/bin/claude path the native installer uses, so the box behaves identically. Bake-time only — changing it re-bakes the snapshot.

HEADS UP

The bake costs a few minutes and a couple euro-cents, but you only do it once per account.

Create a box and run an agent

Once login and prepare are done, create/claude/codex/opencode/pi/shell behave exactly like local Docker — only --provider hetzner (or the pinned config) differs. The workspace is seeded from a host git bundle plus your uncommitted and untracked changes, the same as the other clouds (see teleport a project and sync & git).

$ agentbox create -y --provider hetzner
# VPS provisioned + firewall locked + SSH up (~90s cold, ~15-20s from snapshot)

$ agentbox shell 1 --no-tmux -- uname -a
Linux agentbox-7f3a ... x86_64 GNU/Linux

Or jump straight into an agent, which auto-creates the box:

agentbox claude --provider hetzner

See run an agent, access your box, and background & parallel.

Sizes and regions

The default VM is cx23 (2 vCPU / 4 GB / 40 GB, ~€4/mo while running) in location nbg1 (Nuremberg). On Hetzner, --size is the server type and --location is the datacenter. Change them per box, or pin them with box.sizeHetzner and box.hetznerLocation (precedence: flag > box.size<Provider> > box.size / box.hetznerLocation) — see configuration.

agentbox create -y --provider hetzner --size cx33 --location fsn1

Locations are nbg1 (Nuremberg), fsn1 (Falkenstein), hel1 (Helsinki), ash (Ashburn, US), hil (Hillsboro, US) and sin (Singapore). --size and --location work on agentbox create and on every agent command (agentbox claude --provider hetzner --size cx33 --location hel1). --location on a provider without locations is ignored with a warning. The bake VPS location can be set the same way: agentbox prepare --provider hetzner --location fsn1 (or pin box.hetznerLocation).

The cx server types exist only in the EU locations, so with no --size a box gets its location's default: cx23 in nbg1/fsn1/hel1, cpx21 (3 vCPU / 4 GB) in ash/hil and cpx22 (2 vCPU / 4 GB) in sin. The web create dialog lists that location's sizes once you pick it. An explicit cx* size outside the EU is refused before anything is created, with the types offered there.

When a location has no capacity

Hetzner's EU locations regularly run out of the small shared types (cx23, cx33), and the create comes back resource_unavailable: error during placement. When that happens AgentBox retries the same server type in the other locations of the same network zone (for the EU: nbg1, fsn1, hel1), starting from the configured one, and logs each move:

hetzner: no cx33 capacity in fsn1, trying nbg1

The box record keeps the location it landed in. Locations where the type isn't offered are skipped. Every other location in the zone gets one real attempt, ordered by Hetzner's availability hint, because that hint is often wrong: a type reported unavailable can still be created. AgentBox never moves a box to another zone (US or Singapore) on its own: latency and price differ there, and the cx types aren't offered outside the EU anyway.

  • A location from box.hetznerLocation (or the nbg1 default) fails over.
  • A --location you type for this create pins the box: if that location has no capacity, the create fails instead of moving.

If every location in the zone is full, the error lists the ones tried and suggests a different --size (or box.sizeHetzner), naming a type of the same size that Hetzner reports available there (for example cpx32 when cx33 is sold out). It never switches types for you. It also names locations in other zones where the type is offered.

After the box comes up, AgentBox reports the real provisioned resources read back from Hetzner — e.g. provisioned 4 vCPU / 16 GB RAM / 160 GB disk — rather than a static guess, and stores them on the box record.

Preflight validation

Before AgentBox creates any billable resource (firewall, SSH key, server), it validates your server-type + location choice against Hetzner's live /server_types catalog and fails fast with an actionable message — so a typo never bills you for a half-created box:

  • Unknown type (--size cx99) → lists valid non-deprecated x86 types.
  • ARM type (--size cax31) → rejected; AgentBox base snapshots are x86-only, so cax* types aren't supported.
  • Deprecated type (e.g. the old cx22) → rejected, with current alternatives.
  • Type not offered in the location (--size ccx23 --location nbg1) → lists where it is offered and reminds you of --location.
  • Disk too small for the base snapshot → asks for a larger type.

Dedicated (ccx) types and account limits

New Hetzner accounts start with a low server limit, and the dedicated-vCPU ccx* types count against it quickly. If Hetzner refuses the create with resource_limit_exceeded, AgentBox surfaces the account-limits explanation and points you at the Hetzner Console → your project → Limits to request an increase. An out-of-capacity error (resource_unavailable) is retried in another location; see When a location has no capacity.

Memory and swap

Every Hetzner box gets a /swapfile when it boots: min(RAM, 8 GiB), at least 2 GiB, never more than a quarter of the free disk, with vm.swappiness=10 so it only catches overflow. Without it, an agent running subagents on the default cx23 (4 GB) can be killed by the kernel's out-of-memory killer while agentbox list still says working. The swap survives stop/start and reboots, and control boxes made with agentbox hub deploy hetzner get it too.

Set the size, or turn it off, with box.swap:

agentbox config set box.swap 4G    # a fixed size (or e.g. 2048M)
agentbox config set box.swap off   # no swap
agentbox config unset box.swap     # back to auto

It applies to boxes created after the change. If an agent still runs out of memory, use a bigger --size.

Firewall

Each box gets its own Hetzner Cloud Firewall: inbound TCP port 22 only from the machines you use the box from. All box traffic flows over SSH, so port 22 from your own machines is genuinely all that's exposed.

The allowed set is per machine. The machine that creates the box is added first; when you attach from another computer (with your provider keys and the box's SSH key on it), that computer adds its own egress IP alongside, and neither locks the other out. Each machine only ever replaces its own entry, labelled with its hostname, so a new IP on one machine never removes another's. A box keeps up to 10 entries; past that the least recently written goes first. On a deployed hub, the control box's own entry is never removed.

AgentBox connects to the box over its public IPv4, so the rule admits your host's IPv4 egress address, detected over IPv4 even on a dual-stack (IPv6-capable) network. If no IPv4 egress can be detected (an IPv6-only network, or every probe blocked), the command fails with a message listing what each probe returned. To supply the address yourself, set AGENTBOX_HETZNER_FIREWALL_SOURCE=<cidr> (or use --inbound open) on create, and pass --source <cidr> to agentbox hetzner firewall sync. An address you set by hand is pinned: the automatic repairs leave it alone (useful behind a split-tunnel VPN), and agentbox hetzner firewall sync <box> without --source switches back to detection. --source does not take 0.0.0.0/0; to open SSH to the world use agentbox inbound <box> open, and agentbox inbound <box> locked closes it again.

If you change networks (new Wi-Fi, VPN toggle), your egress IP changes. The relay notices: it re-checks your IP every 5 minutes (only while you have a running Hetzner or DigitalOcean box, so it makes no calls otherwise) and updates this machine's entry on every running box. The first attach after a change also repairs it. To do it by hand, agentbox hetzner firewall sync <box> re-detects your IP and updates this machine's entry with no reboot:

agentbox hetzner firewall sync smoke

TIP

Moved networks and agentbox shell times out before the relay caught up? Run agentbox hetzner firewall sync <box>. agentbox hetzner firewall show <box> lists which machine owns which address.

To reach a box from another device (a phone over Terminus/Blink, with your laptop off), open the firewall and hand the device a key: agentbox inbound <box> open then agentbox connect <box> --add-key <device.pub>. The baked sshd is key-only (vscode-only, no passwords), so open exposes port 22 to the internet but only your keys get in. See remote access.

Web apps, checkpoints, and Docker

The box's standard capabilities work as on any provider, with a few Hetzner specifics:

  • Web apps / preview URLs. agentbox url <box> returns a URL, and the in-box portless proxy mirrors it so https://<box-name>.localhost resolves the same content from your host browser and from inside the box. agentbox screen works too. See web apps & tunnels and browser & screen.
  • Checkpoints map to Hetzner create_image snapshots (no-pause by default, matching docker commit). A running box's disk is flushed first; if that fails the checkpoint is refused, so retry or stop the box and checkpoint it while it is off. Set a per-provider default with agentbox checkpoint set-default --provider hetzner <ref>. See checkpoints & pausing.
  • Docker-in-Docker works unmodified. See Docker-in-Docker.
  • Services & tasks from agentbox.yaml run via the in-box supervisor. See services & tasks.
agentbox checkpoint create smoke setup

TIP

Because Hetzner checkpoints are full-disk snapshots, capturing one after your project's setup lets later boxes boot ready-to-go and skip workspace seeding.

Specs

Spec
Base imageUbuntu 24.04 snapshot
Build methodBaked snapshot — install script on a throwaway VPS then create_image (agentbox prepare --provider hetzner); no Dockerfile
Docker-in-DockerYes (full root, unmodified)
SSHYes — one persistent OpenSSH ControlMaster per box
Archx86_64 (amd64)
Live snapshotscreate_image snapshots (no-pause default); pause = poweroff/poweron and a stopped VPS still bills ~€4/mo
Preview URLSSH local port forward via ssh -O forward, mirrored to https://<box-name>.localhost (Portless)

Caveats

  • Pause still bills. Hetzner charges ~€4/mo even for a stopped VPS. Destroy the box (agentbox destroy <box> -y) to stop billing entirely — it deletes the VPS, its firewall, and the per-box SSH key.
  • No live stats. agentbox top and dashboard render — for CPU/mem; the basic API doesn't expose per-server metrics.
  • No shared credential volume. Agent credentials are pushed to each box via scp at create time.
  • Agent env rides a 0600 file, not the VPS user data. Cloud-init user data is readable from inside the box, so forwarded keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, ...) and a named account's token are written to /run/agentbox/agent.env (mode 0600, box user) at create and on every start, and the agent launcher sources it. They are re-read from the host that starts the box, so start it from where those keys are set.
  • IPv4 only. SSH targets the VPS's IPv4 address; IPv6-only host networks aren't exercised yet.
  • agentbox prune --provider hetzner isn't wired yet. Clean up orphans from the Hetzner dashboard or the REST API ($HCLOUD_TOKEN lives in ~/.agentbox/secrets.env).

HEADS UP

Destroying is the only way to stop billing. A stopped box keeps accruing the ~€4/mo charge.

On this page