Hetzner vs DigitalOcean for AI Coding Agents: Which VPS in 2026?
How to provision a VPS, install Claude Code, add basic security hardening, and keep sessions running persistently with tmux. Covers DigitalOcean, Hetzner, and AWS EC2.
TL;DR
Hetzner's CPX22 at ~$9.49/month beats DigitalOcean on price for running Claude Code 24/7 — by a significant margin. Claude Code is API-bound, not compute-bound, so you need enough RAM to keep the process alive, not a beefy CPU. European developers should default to Hetzner; US developers who want simpler tooling and less ops overhead can justify DigitalOcean's premium. If you want to skip VPS provisioning entirely, Grass provides always-on cloud VMs pre-configured for coding agents — no Linux hardening required.
Why does your VPS choice matter for coding agents?
Most "VPS comparison" articles are written for web servers or databases. Coding agents have a completely different resource profile. Claude Code doesn't run inference locally — that happens on Anthropic's servers. What your VM is actually doing is:
- Keeping a Node.js process (the Claude Code CLI) alive
- Maintaining an SSH-accessible terminal session
- Reading and writing files in your project repo
- Firing shell commands as the agent executes tool calls
That workload is lightweight. You're not CPU-bound. You're not GPU-bound. You need enough RAM to hold the agent process, your project's source tree in memory, and a shell session or two. 2 vCPU / 4GB RAM is the practical sweet spot for a single active agent. 1 vCPU / 2GB will work for smaller repos but risks OOM kills under heavier tool use.
The $5–10/month tier is sufficient for most developers running one or two parallel coding sessions.
What are the minimum specs for running Claude Code on a VPS?
Based on what Claude Code actually needs:
| Resource | Minimum | Recommended |
|---|---|---|
| vCPU | 1 | 2 |
| RAM | 2 GB | 4 GB |
| Disk | 20 GB SSD | 40 GB SSD |
| Bandwidth | 1 TB/mo | 4 TB+ |
| OS | Ubuntu 22.04+ | Ubuntu 24.04 LTS |
The RAM floor is 2GB — Claude Code's Node.js process, your project files, and a tmux session fit comfortably. Go below 2GB and you'll see the OOM killer show up mid-task. The disk recommendation assumes you're cloning repos and building occasionally; if you're running Docker inside the VM add another 20GB.
CPU matters less than you'd expect. Agent tasks are largely I/O-bound: waiting on API responses, reading files, running shell commands. A shared-CPU instance at the 2 vCPU tier is fine.
Hetzner vs DigitalOcean: the actual numbers
Pricing sourced from BetterStack's 2026 comparison.
Price
| Plan | Provider | vCPU | RAM | Price/mo |
|---|---|---|---|---|
| CPX22 | Hetzner | 2 | 4 GB | ~$9.49 (€7.99) |
| Basic Droplet | DigitalOcean | 2 | 4 GB | $24.00 |
Hetzner is roughly 60% cheaper for the same tier, even after the April 2026 price increase. At $9.49 vs $24, that's $174/year in difference — meaningful for a personal or small-team setup.
Bandwidth
| Provider | Included Transfer | Overage |
|---|---|---|
| Hetzner (EU) | 20 TB/mo | Metered |
| DigitalOcean | 4 TB/mo | $0.01/GB |
Coding agents generate minimal outbound traffic. You're not serving web requests. The bandwidth difference won't matter unless you're running a lot of git clone operations on large repos or pulling Docker images constantly.
Performance
For the 2 vCPU / 4 GB tier:
- CPU (Geekbench 6 single-core): Hetzner ~939 vs DigitalOcean ~772 — a ~22% gap in Hetzner's favor
- Disk IOPS (4K): DigitalOcean ~54k vs Hetzner ~41k — DigitalOcean wins on storage throughput
- Network: Hetzner dominates for European endpoints; DigitalOcean is better positioned for US-east routing
For coding agents, neither CPU performance nor disk IOPS are bottlenecks in normal operation. You won't notice the difference in practice.
Developer experience
This is where DigitalOcean earns its premium. The gap shows up in:
- Documentation: DigitalOcean's tutorials are thorough and well-maintained. Hetzner's docs are thinner.
- Support: DigitalOcean's support tier is more responsive at the base plan level.
- Managed add-ons: If you eventually want a managed Postgres ($15/mo entry) or managed Kubernetes alongside your agent VM, DigitalOcean's ecosystem is more mature.
- Team access controls: DigitalOcean has better multi-user project management, relevant for teams sharing a VM fleet.
Hetzner's UI is functional but sparse. Provisioning is fast, the API works well, and the network performance in Europe is excellent. If you're comfortable with Linux and don't need hand-holding, Hetzner's limitations are non-issues.
What about Hostinger for US developers on a budget?
Hostinger sits below both options on price — around $5/month for a KVM 1 plan (1 vCPU, 4GB RAM). More relevant: Hostinger offers a browser-based terminal and a pre-built Claude Code template in their VM marketplace, which removes a few steps from the setup process.
The tradeoff is datacenter coverage. Hostinger's US presence is thinner than DigitalOcean's, and their network performance benchmarks less consistently. For a developer in the US who wants the cheapest possible setup with a shorter path to a running Claude Code session, Hostinger is worth considering. For production-grade agent work or teams, the infrastructure maturity of DigitalOcean or Hetzner is worth the cost.
How do you actually set up a coding agent on a fresh VPS?
This assumes Ubuntu 24.04. The core steps are the same across providers.
1. Harden the server first (run as root)
apt update && apt upgrade -y
adduser claude
usermod -aG sudo claude
ufw allow OpenSSH
ufw allow 443
ufw enable
apt install -y fail2ban tmux
Disable root SSH login:
sed -i 's/^PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
systemctl reload sshd
Switch to your new user:
su - claude
2. Install Claude Code
curl -fsSL https://claude.ai/install.sh | bash
claude doctor
The claude doctor command checks your Node version and environment. Fix any warnings before proceeding.
3. Authenticate
The VPS has no browser. Claude Code's OAuth flow gives you a URL — copy it to your local browser, complete auth, and the token gets stored server-side.
claude auth login
# Copy the displayed URL to your local browser
# Auth token is saved to ~/.claude/config
4. Run in a persistent tmux session
tmux new -s agent
cd /path/to/your/repo
claude
Detach with Ctrl+B, D. The session stays alive. Reconnect from anywhere:
ssh user@your-vps-ip
tmux attach -t agent
5. Keep sessions alive across reboots
Create a systemd service or add a tmux session auto-start to your .bashrc / .zshrc. For single-agent setups, a simple cron @reboot tmux new -d -s agent is enough.
Decision matrix: which provider should you pick?
| Scenario | Recommendation |
|---|---|
| European developer, cost-sensitive | Hetzner CPX22 (~$9.49/mo) |
| US developer, minimal ops overhead | DigitalOcean Basic ($24/mo) |
| US developer, absolute cheapest | Hostinger KVM 1 (~$5/mo) |
| Team with shared agent fleet | DigitalOcean (project/team controls) |
| Running Docker or multiple parallel agents | Hetzner CPX32 or DO 4GB+ |
| Don't want to manage a VPS at all | Grass (pre-configured, always-on) |
The short version: Hetzner if you want to optimize cost and are comfortable with Linux. DigitalOcean if you want a smoother ops experience and the price delta doesn't matter.
What about a VM that's already configured for coding agents?
If you've read this far and thought "I just want this running without setting up UFW, fail2ban, and tmux configs" — Grass is worth looking at.
Grass provides always-on cloud VMs that are pre-configured for running coding agents. You're not provisioning a raw Ubuntu box; the Daytona VM environment is already set up for Claude Code and OpenCode. The pitch is that you skip the sysadmin layer entirely: no hardening, no session management configuration, no reconnecting to tmux sessions.
A few specifics that are relevant if you're comparing this to a DIY VPS setup:
- Agent-agnostic: Works with Claude Code and OpenCode, not locked to one provider
- BYOK: Your Anthropic API key stays yours — Grass never touches it
- Session persistence: Sessions survive disconnects; you reconnect and pick up where you left off
- Permission forwarding: You can approve or deny tool calls (bash commands, file writes) from your phone via a native modal — useful when you're away from your laptop
- Mobile control: Monitor, steer, and push changes from your phone
- Free tier: 10 hours, no credit card required
The tradeoff is control. If you want to run arbitrary Docker containers alongside your agent, install custom system packages, or configure the network yourself, a raw VPS gives you more latitude. If you want the agent to just run, Grass removes most of the setup surface.
FAQ
Can I run Claude Code on a $5/month VPS?
Yes, with caveats. You need at least 2GB RAM — the 1GB tier will OOM under normal agent use. Hostinger's KVM 1 at ~$5/mo includes 4GB RAM, which is sufficient. Hetzner's CX22 (the shared ARM option) also hits around $4/mo and works fine for light agent use.
Does Claude Code use a lot of CPU or bandwidth?
No to both. Inference runs on Anthropic's API servers. Your VM is just running the CLI process, maintaining a terminal session, and executing file/shell operations. A 2 vCPU shared instance handles this easily. Bandwidth usage is minimal unless you're doing heavy git or Docker operations.
How do I keep my Claude Code session running when I disconnect?
Use tmux or screen. Start a session with tmux new -s agent, run your agent inside it, and detach with Ctrl+B, D. SSH into the server later and run tmux attach -t agent to resume. The agent keeps working while you're offline.
Is Hetzner reliable enough for always-on agent workloads?
Hetzner's uptime SLA for cloud VMs is 99.9%. For agent workloads that tolerate occasional brief downtime (the agent just pauses and resumes), Hetzner's reliability is sufficient. If you need higher availability guarantees or are running business-critical automation, DigitalOcean's SLA and support tiers are more robust.
What's the difference between Hetzner's CPX and CX lines?
CX instances use Intel or AMD shared CPUs with conventional performance. CPX instances use AMD EPYC with better per-core performance for burstable workloads. For coding agents, the CPX22 at ~$9.49/mo is the better pick — the CPU burst headroom is useful when the agent is running a lot of shell commands in quick succession. The CX22 is slightly cheaper but the performance difference is worth the few dollars.