Claude Code on a VPS or a per-second microVM: where the break-even sits
Last updated
Below how many hours a month a per-second VM costs less than a VPS
- Minimum specs: Anthropic lists "4 GB+ RAM, x64 or ARM64 processor"; 2 vCPU / 4 GB fits one agent.
- Lowest no-commitment price in the table below: OVHcloud VPS-1 (2 vCPU / 4 GB), €4.49 a month, about $5.02 (€3.81 with 12 months upfront; rechecked on 5 November 2026).
- Break-even: below about 30 hours of agent time a month, E2B's per-second rate ($0.1656 an hour) costs less than that VPS; above it, the VPS does.
A VPS is the cheaper home for Claude Code when one agent runs most of the day, every day. A VM billed per second is cheaper when agents run in bursts, or when you want ten of them for two hours and none the rest of the time. The line between the two is a number of hours per month. On 31 October 2026, for 2 vCPU / 4 GB, it sat between 26 and 145 hours a month against E2B's rates, and between 121 and 680 hours against Fly.io's.
| If you… | Pick | Why |
|---|---|---|
| keep one agent running most days | A VPS (from €4.49 a month) | Cheapest past the break-even below |
| run agents a few hours a week | Per-second VMs | You pay for the hours used, nothing in between |
| start 5 to 20 agents for a task, then stop | One VM per agent, deleted after | Own kernel per agent; no server to maintain |
| skip permissions on code you don't fully trust | One VM per agent | On a shared VPS, each agent reads what the others can |
All prices on this page are before VAT or sales tax and were read on 31 October 2026. Euro prices are converted at the ECB rate of 30 October 2026: 1 EUR = 1.1172 USD.
Do you need a VPS to run Claude Code?
No. People move Claude Code to a server so the session survives a sleeping laptop, so long tasks run overnight, and so the agent's mistakes happen away from their personal files.
Anthropic's cloud sessions, on Pro, Max, Ultra and Team plans, also keep going after you close the laptop, with "no separate charge for the cloud VM". A machine of your own covers what they don't: your own services and images, more memory, control over where the code runs. Claude Code in the cloud compares the two. How to run Claude Code agents in parallel compares the options by agent count.
"Self-hosting" Claude Code means hosting the client, the repository and its tools. The model itself still runs at Anthropic or at a cloud provider such as Amazon Bedrock.
What size VPS does Claude Code need?
Anthropic's setup page lists the floor: "4 GB+ RAM, x64 or ARM64 processor", on Ubuntu 20.04+, Debian 10+ or Alpine Linux 3.19+. The native installer needs no Node.js, and ARM servers such as Hetzner's CAX line work.
Your project adds its own needs on top: tests, a dev server, a database, Docker. As a rule of thumb, start at 2 vCPU / 4 GB for one agent (the size compared below), go to 4 vCPU / 8 GB for Docker Compose stacks or heavy builds, and add the same again for each extra agent on the server, each in its own git worktree.
How much does a VPS for Claude Code cost?
Public prices for the smallest plan with at least 2 vCPU and 4 GB, read on 31 October 2026:
| Provider and plan | vCPU / RAM / disk | Monthly price | In USD | Billing |
|---|---|---|---|---|
| OVHcloud VPS-1 (2027 range) | 2 / 4 GB / 40 GB NVMe | €4.49 without commitment, €3.81 with 12 months upfront | $5.02 / $4.26 | Monthly, no installation fee |
| Hetzner Cloud CX23 (cost-optimized) | 2 / 4 GB / 40 GB NVMe | €5.99, or €0.0096 per hour | $6.69 | Hourly, capped at the monthly price |
| Hostinger KVM 2 | 2 / 8 GB / 100 GB NVMe | $8.79 with 24 months paid upfront ($210.96), renews at $14.99 | $8.79 / $14.99 | Term paid in advance |
| DigitalOcean Basic Droplet | 2 / 4 GiB / 80 GiB SSD | $24, or $0.03571 per hour | $24.00 | Per second, 60 s minimum, capped at 672 hours a month |
Three details the plan cards don't put first:
- Hostinger has no 2 vCPU / 4 GB plan. KVM 1 is 1 vCPU / 4 GB, so the comparable row is KVM 2, with twice the RAM, and its price needs 24 months paid at once.
- Hetzner was out of stock. On 31 October 2026, every cost-optimized plan, CX23 included, showed "This product is currently unavailable. Please check back later." The regular-performance CPX22 (2 vCPU / 4 GB, €19.99) could still be ordered.
- DigitalOcean already bills per second, at almost Fly.io's hourly price. The difference is what happens when the machine is off, covered below.
When does a per-second microVM cost less than a VPS?
flockvm's own rates, and its $18 monthly plan that comes back as VM time, are on its pricing page. This page uses two other public per-second rate cards, for 2 vCPU / 4 GB:
- E2B: 2 × $0.000014 per vCPU-second + 4 × $0.0000045 per GiB-second = $0.000046 per second, $0.1656 per hour.
- Fly.io,
shared-cpu-2xwith 4 GB, iniadandewr(its cheapest regions): 2 × $0.0000008465 per shared vCPU-second + 3.5 GB × $0.000002316 per GB-second beyond the 0.5 GB included = $0.0000098 per second, $0.0353 per hour. The same formula gives Fly's published $13.39 a month for 2 GB.
Break-even = the VPS's monthly price ÷ the per-second hourly price. Below that many hours a month, the per-second VM costs less.
| VPS (2 vCPU) | Monthly, USD | Break-even vs E2B ($0.1656/h) | Break-even vs Fly.io ($0.0353/h) |
|---|---|---|---|
| OVHcloud VPS-1, 12 months upfront | $4.26 | 26 h | 121 h |
| OVHcloud VPS-1, no commitment | $5.02 | 30 h | 142 h |
| Hetzner CX23 | $6.69 | 40 h | 190 h |
| Hostinger KVM 2, first term | $8.79 | 53 h | 249 h |
| Hostinger KVM 2, renewal | $14.99 | 91 h | 425 h |
| DigitalOcean 2 vCPU / 4 GiB | $24.00 | 145 h | 680 h |
For scale: 22 working days of 8 hours is 176 hours, which costs $29.15 at E2B's rates and $6.21 at Fly.io's. A full month (730 hours) costs $120.89 and $25.77 (730 × $0.1656 and 730 × $0.0353), against $4.26 to $24 for the VPS rows.
Two things move the line:
- Plan fees. E2B's free Hobby plan comes with a $100 one-time credit, sessions of at most 1 hour and 20 concurrent sandboxes. Pro allows 24-hour sessions for $150 a month before usage: for one agent, more than any VPS here.
- Hourly cloud servers. Hetzner bills by the hour. A server created for a task and deleted afterwards costs €0.0096 an hour, less than both rate cards, but deleting it deletes its disk, and snapshots are a paid add-on.
What a swarm costs
Take ten agents, each running two hours a day, 22 days a month: 10 × 2 × 22 = 440 VM-hours.
| Setup | Cost per month | What you get |
|---|---|---|
| E2B, 2 vCPU / 4 GiB per agent | 440 × $0.1656 = $72.86 | One sandbox per agent, pause with memory |
Fly.io, shared-cpu-2x 4 GB per agent |
440 × $0.0353 = $15.53 | One Firecracker VM per agent |
| Hetzner CX23, created and deleted per task | 440 × €0.0096 × 1.1172 = $4.72 | One full VM per agent, set up again each time unless you build an image |
| One Hetzner CX53 (16 vCPU / 32 GB) for all ten | €29.99 = $33.50 | 3.2 GB per agent, below Anthropic's 4 GB floor; one shared OS, agents can read each other's files |
Raw compute is cheap everywhere. The per-second services charge for the lifecycle: a prepared image, pause and resume, an API that creates and deletes VMs. If you run a swarm of coding agents, that tooling is most of the work.
A month of a swarm, at per-second rates
An estimate, per month, from the page's numbers:
- E2B, 2 vCPU / 4 GiB per agent = agents × 2 hours a day × 22 days a month × $0.1656 per hour
- Fly.io, shared-cpu-2x 4 GB per agent = agents × 2 hours a day × 22 days a month × $0.0353 per hour
How do you set up Claude Code on a VPS?
This page is about cost; the full walkthrough for any remote Linux box (install, sign-in, tmux, headless runs over SSH) is in Claude Code on a remote server. The short version for a VPS follows.
This recipe targets a fresh Ubuntu 24.04 server reached as root with an SSH key. It creates an agent user without sudo, so the agent can't change the system even with its permission prompts skipped. Run steps 1 to 4 as root.
1. Create the agent user
adduser --disabled-password --comment "" agent
install -d -m 700 -o agent -g agent /home/agent/.ssh
cp /root/.ssh/authorized_keys /home/agent/.ssh/
chown agent:agent /home/agent/.ssh/authorized_keys
2. Lock down SSH
Keys only, no passwords, root by key only:
cat > /etc/ssh/sshd_config.d/10-hardening.conf <<'EOF'
PasswordAuthentication no
KbdInteractiveAuthentication no
PermitRootLogin prohibit-password
EOF
sshd -t && systemctl reload ssh
sshd keeps "the first obtained value" of each setting, and the files in sshd_config.d/ are included in name order, so a 10- file wins over a later one, such as a 50-cloud-init.conf that sets PasswordAuthentication yes. Test a new login before you close the current session.
3. Firewall
Allow SSH, refuse everything else coming in:
ufw allow OpenSSH
ufw --force enable
--force skips the prompt "Command may disrupt existing ssh connections. Proceed with operation (y|n)?", which would stop a pasted block or a script; the allow OpenSSH rule comes first, so your session stays open.
If your provider offers a network firewall in its console, set the same rule there too.
4. Updates
apt update && apt full-upgrade -y
apt install -y unattended-upgrades tmux git
dpkg-reconfigure -plow unattended-upgrades
unattended-upgrades applies security updates on its own. Claude Code's native install updates itself "in the background", effective at the next start.
5. Install Claude Code as the agent user
su - agent
curl -fsSL https://claude.ai/install.sh | bash
claude --version
This is Anthropic's native installer; it puts the launcher in ~/.local/bin/claude. If claude isn't found, open a new login shell.
6. Sign in
Sign in on the server itself, one of two ways:
- Your Claude plan: start
claudeon the server and run/login(or runclaude auth loginbefore the first session), open the URL it prints on your laptop, and paste the code back atPaste code here if prompted. On Linux the login lands in~/.claude/.credentials.json, mode0600. - An organization API key from the Claude Console, as
ANTHROPIC_API_KEY, billed per token.
Whichever you choose, the agent can read it. Don't copy a token over from your laptop; with an API key, give the server a key of its own, so you can revoke it alone.
7. Keep the session alive with tmux
tmux new -s claude
cd ~/your-repo && claude
Detach with Ctrl-b then d and the agent keeps working; come back with tmux attach -t claude. Claude Code in tmux covers one window per agent and scripted sessions.
8. Reach it from your phone
Start with claude --remote-control and the session appears in the Claude app and at claude.ai/code, while the code runs on your server. It needs a claude.ai subscription login: "API keys are not supported".
Is a VPS isolated enough for --dangerously-skip-permissions?
From other customers, yes: the provider's hypervisor separates your VPS from theirs. From your own agents, it depends on how many share the server.
With one agent per VPS, the blast radius is that server: the repository, the Claude credential, any git token you put there. The non-root agent user stops it from changing the system, not from reading or sending what that user can read.
With several agents on one VPS, they share a kernel, a network and usually a user. An agent that runs a bad command, or follows instructions planted in a README, can read the others' files and credentials. A container per agent narrows that; a VM per agent closes it, with its own kernel and disk, deleted when the task is done.
Running Claude Code with --dangerously-skip-permissions safely tests which layer blocks what, from the sandbox built into Claude Code to a remote VM.
What happens to the bill when the agent is idle?
This is where the two differ most.
- A VPS bills while it is off. DigitalOcean: "You are still billed for bundled-plan CPU Droplets that are powered off". Hetzner bills each server "until you choose to delete them". To stop paying, you delete the server and its disk.
- Per-second VMs bill while they run. E2B charges "per second of a running sandbox"; a paused sandbox keeps files and memory, and pausing takes "approximately 4 seconds per 1 GiB of RAM". A stopped or suspended Fly.io machine costs $0.15 per GB of root filesystem a month. Fly's suspend keeps memory too, but Fly lists 2 GB of memory or less as a requirement and discourages it above that, so plan on stopping the 4 GB machine priced here.
Memory matters because an agent's state is not only on disk: a dev server, a database with test data, a half-finished test run are still there after a resume, and gone after a reboot. Firecracker snapshot and restore explains how the memory snapshot works.
The agent is idle: what is billed, what is kept
| Machine | The bill while idle | The agent's state |
|---|---|---|
| A VPS | Gap: Bills while it is off | To stop paying, you delete the server and its disk |
| E2B sandbox | Strength: Charged per second of a running sandbox | A paused sandbox keeps files and memory |
| Fly.io machine | Partial: Stopped or suspended: $0.15 per GB of root filesystem a month | Suspend keeps memory too, but Fly lists 2 GB of memory or less as a requirement: plan on stopping the 4 GB machine priced here |
Where flockvm fits
flockvm runs one Firecracker microVM per coding agent, on one host in France (OVHcloud). Sign-ups are open (Google, GitHub or an email link), with a 7-day free trial: card required, nothing charged for 7 days, cancel anytime. Today:
- Cold boot in about a second: 0.43 to 1.34 s from creation to SSH answering, median about 1.1 s, over 12 VMs on the Agent image, measured on the host in France on 9 and 10 November 2026.
- Pause and resume with memory: 2.6 to 3.3 s to pause a 4 GiB VM on a quiet host, 7.5 to 17 s while the host writes other data, measured on 31 October 2026 on the Paris host, retired since. Open SSH connections survive the pause.
- SSH, logs, per-second billing, with an $18 monthly plan that comes back as VM time (pricing).
- At most 15 small VMs (2 vCPU / 4 GiB) at once, across all customers, 2 during the trial: the host in France gives its VMs 30 vCPU in all. France is the one region today; others are planned.
Not there yet: no fork, no SDK (there is a REST API, a CLI and an MCP server), no public status page, and the Claude login or API key you give the agent stays in the VM (use a key you can revoke). Swarms of 10 to 20 agents and forking are what flockvm is building next. If one agent on a €5 VPS does the job, keep the VPS. If you want a fresh VM per agent and a pause that keeps services running, create an account. The quickstart goes from sign-up to an SSH shell in a VM, and Claude Code in a VM shows the setup; flockvm vs exe.dev compares a flat monthly pool of SSH VMs with per-second ones; GitHub Codespaces alternatives covers hosted development environments, and flockvm vs Ona covers Ona, formerly Gitpod, closed to new customers; E2B alternatives compares other per-second providers.
Which should you pick?
- One agent, most of the day: a VPS, such as OVHcloud VPS-1 at €4.49 a month without commitment, set up with the recipe above and signed in on the server itself.
- A few hours a week: per-second VMs, below the break-even in the table.
- Several agents at once, for a task: one VM per agent, deleted or paused afterwards. Hourly cloud servers are the cheapest compute if you build the tooling; per-second services sell it.
- Untrusted code with skipped permissions: one VM per agent, never a shared server.
Prices change; the formula doesn't: your VPS's monthly price divided by the per-second hourly price for the same size.
Run your agents in their own microVMs
flockvm gives each coding agent a Firecracker microVM that pauses with its memory and resumes, billed per second. France is live, and you can start with a 7-day free trial.
Start your 7-day free trialCard required. Nothing charged for 7 days.