Running an AI agent 24/7 on a $5 VPS: the realistic setup
TL;DR
- To run an AI agent on a VPS around the clock, a $5-6/month entry-tier instance (1 vCPU, 2 GB RAM) is sufficient for any API-based workload.
- Hetzner and OVHcloud are the only EU providers under €4/month in 2026.
- Pair Docker Compose with a systemd unit (
Restart=always) for automatic crash recovery. - Local LLM inference does not fit this tier: you need at least 8 GB RAM.
- A free Uptime Kuma heartbeat check catches silent failures within minutes.
The fastest way to run an AI agent on a VPS costs five dollars a month and takes under an hour to configure. If the agent already works on your laptop, the only remaining gap is keeping it alive around the clock without your supervision.
Managed platforms like Modal, Replicate, or Railway charge per invocation with a markup. That's sensible for burst workloads, but expensive for a persistent background worker that polls an API every sixty seconds. A bare Linux VPS removes that overhead entirely.
What follows is an honest breakdown: which hardware tier you need, how to pick a provider in 2026, the deployment stack that auto-restarts on crash, and a zero-cost monitoring setup that catches silent failures.
Why your laptop is the wrong place to keep an agent running
A long-lived process on a laptop runs into three failure modes that have nothing to do with your code.
Sleep is the first. Every time the lid closes or the screensaver triggers, macOS and Windows suspend background processes. An agent waiting on a webhook or polling an external API at a fixed interval drops its connection without producing a crash log.
Network instability is the second. Home and office connections switch between WiFi and wired interfaces, change IP addresses on router reboots, and lose connectivity during ISP maintenance windows. A cloud automation running in a data centre sits behind a static IP on redundant uplinks (a meaningfully different reliability profile).
Resource contention is the third. A browser with thirty tabs, a video call, and a local dev server compete for the same CPU and RAM as your agent. A VPS gives you isolated compute: the 2 GB of RAM on the machine belongs to your process alone.
The practical baseline for a commodity VPS is a 99.9% uptime SLA, roughly 8.7 hours of allowed downtime per year. A laptop that sleeps eight hours nightly consumes that entire budget in forty-four days.
The conclusion is clear: run an AI agent on a VPS, not a laptop, for any process that needs to stay alive around the clock.
What a $5 VPS actually handles (and what it can't)
The reference machine for this article is the Hetzner CX11: 1 shared vCPU, 2 GB RAM, 20 GB NVMe storage, at approximately €3.29/month as of mid-2025.
An agent that calls the OpenAI or Anthropic API to handle inference idles between 50 and 150 MB of RAM in Python or Node.js. The heavy computation happens on the API provider's infrastructure, not yours. A headless runner that polls a REST endpoint every minute, applies business logic, and triggers a follow-up action (email, webhook, Slack message) fits comfortably inside 2 GB. You can run several of these concurrently in separate Docker containers on the same machine without pressure.
What does not fit: local LLM inference. A quantised 7B-parameter model needs at least 6 to 8 GB of RAM to run without swapping to disk, which lands you in the $20-30/month tier. GPU inference requires dedicated GPU nodes (a different product category entirely).
The rule is simple: if the model runs on someone else's server, the $5 tier works. If you want the model on your server, the $5 tier does not.
How to run an AI agent on a VPS: provider comparison for 2026
The four providers most cited in self-hosting communities for budget deployments:
| Provider | Tier | Price | RAM | EU data centre | Egress |
|---|---|---|---|---|---|
| Hetzner | CX11 | ~€3.29/mo | 2 GB | Falkenstein, Helsinki | 20 TB free |
| OVHcloud | VPS Starter | ~€3.50/mo | 2 GB | Gravelines (FR) | Unmetered |
| DigitalOcean | Basic Droplet | $6/mo | 1 GB | Amsterdam, Frankfurt | 500 GB free |
| Vultr | Cloud Compute | $6/mo | 1 GB | Amsterdam, Frankfurt | 500 GB free |
Hetzner and OVHcloud are the only two options under €4/month with a European data centre in 2026. If GDPR-sensitive data flows through the agent, or you need low latency to EU users, these are the default choice. OVHcloud's Gravelines facility sits inside the EU; their routing is straightforward for compliance purposes.
DigitalOcean and Vultr deliver less RAM at a higher price at the entry tier, but their control panels and API documentation are more accessible if your team is less comfortable with raw Linux administration. Both provide a one-click Ubuntu 24.04 LTS install and a built-in firewall configuration UI.
One practical detail: Hetzner and OVHcloud both require a credit card or SEPA mandate and run a brief account review for new signups. Allow 24 to 48 hours before the machine is provisioned if you are registering for the first time.
The minimal deployment stack: Docker Compose and a systemd unit
Two layers provide everything you need to keep a remote process running reliably at this scale.
Docker Compose gives you a reproducible environment. Your agent code, its runtime dependencies, and its environment variables are declared in a single compose.yml. On a fresh machine, docker compose up -d brings the entire stack up in one command, with no manual dependency installation.
A systemd unit supervises the process at the OS level. The two critical directives are Restart=always and a short RestartSec:
[Unit]
Description=AI agent service
After=docker.service
Requires=docker.service
[Service]
WorkingDirectory=/opt/agent
ExecStart=docker compose up
ExecStop=docker compose down
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Save this to /etc/systemd/system/agent.service, then run systemctl enable --now agent.service. The persistent automation survives reboots, crashes, and OOM kills without any manual intervention. This two-layer approach lets you run an AI agent on a VPS with automatic recovery built in at the OS level.
Kubernetes is not the right tool here. Its control plane alone exceeds the RAM of the target machine. For a single-agent workload, the Compose-plus-systemd pattern covers the correct scope.
Running without Docker: venv + systemd on Ubuntu 24.04
If you prefer no Docker, pin dependencies with a requirements.txt (Python) or package-lock.json (Node.js), install into a virtual environment, and point ExecStart directly at the interpreter. The Restart=always behaviour is identical.
Environment variables and secrets
Place a .env file at /opt/agent/.env and load it in the compose file with env_file: .env. This file never enters version control. If you use a secrets manager such as Infisical or HashiCorp Vault, inject values at deploy time with a wrapper script rather than persisting them on disk.
Monitoring, crash recovery, and knowing when the agent goes silent
Restart=always handles transient crashes: the process is back within five seconds of exiting. What it does not catch is a live process that has stopped doing useful work (for example a deadlock, an infinite retry loop, or an expired API token). For that failure mode, an external heartbeat check is necessary.
Uptime Kuma is a self-hosted monitoring tool you can run on the same VPS in a second Docker container. Configure the agent to POST to a heartbeat URL on every successful iteration. If Uptime Kuma stops receiving that request within the expected window, it sends an alert by email, Slack, or Telegram. Cost: zero.
BetterStack's free tier provides one heartbeat monitor with a 30-second check interval without requiring self-hosting. That's enough for a single-agent deployment.
For logs, write structured JSON lines to stdout and let Docker capture them. Cap log file size in the compose file to bound disk usage:
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
Three ten-megabyte files provide enough history to debug most crash patterns without a separate logrotate configuration. Systemd restart plus an external heartbeat plus capped structured logs covers the common failure modes for a single always-on server at no additional monthly cost.
Actually, let me put it differently. I've been running agents this way for months now and the setup is surprisingly solid 🚀 The main gotcha is forgetting to set up the heartbeat check initially, then wondering why a stuck process didn't trigger any alerts.
Key takeaways
The correct tier to run an AI agent on a VPS for API-based workloads in 2026 is a $5 entry machine. Hetzner and OVHcloud are the two sub-€4/month EU options. Pair Docker Compose with a systemd unit for automated crash recovery, add a free Uptime Kuma heartbeat to detect silent failures, and cap Docker log files to keep disk usage bounded.
The upgrade trigger is unambiguous: local LLM inference requires at least 8 GB RAM and a $20-30/month machine.
Running a persistent agent on $5/month means keeping it alive without your laptop, and the setup checklist matters more than the hardware. The demo-vs-product checklist in the welcome kit shows you exactly what separates a script that runs once from one that runs forever without silent failures.