How to Deploy Your Own AI Agent on a 5 Dollar VPS: The Complete Guide
You can run your own AI agent on a $5/month VPS right now. Not some stripped-down demo version — a real, production-ready AI assistant that runs 24/7, connects to your favorite messaging apps, and costs less than your morning coffee.
Most people think self-hosting an AI assistant is complicated. It was, two years ago. In 2026, the process takes about 30 minutes and requires zero Linux expertise beyond knowing how to copy-paste commands.
This is a practical guide to exactly what works, with actual numbers and specific recommendations based on real deployments.
Why Would You Self-Host an AI Agent?
Before we get into the how, let’s address why you would self-host instead of just using Claude.ai or ChatGPT.
Privacy. Your conversations stay on your server. No third-party servers, no data processing by the tool provider, no training on your conversations.
Cost. After the initial $5/month VPS investment, you pay only for your API key usage. For personal use at moderate volumes, that’s often under $10/month total. Compare that to $20/month for a Claude Pro subscription — and you get multi-platform support, custom skills, and full control.
Availability. Your agent runs on your server. If Anthropic has an outage (it happens), your assistant keeps working. If OpenAI changes their pricing (they do that), your cost structure doesn’t change.
Customization. Install community skills to extend what your agent can do. Connect it to your calendar, email, GitHub repos, Notion workspace. Make it work the way you work.
The VPS approach isn’t for everyone. If you just want a chat interface and don’t care about the infrastructure, use the web version. But if any of the above matters to you, self-hosting is worth 30 minutes of setup.
What VPS to Use
I’ve tested deployments on Hetzner, DigitalOcean, Vultr, and Ramnode. Here’s the honest breakdown:
Hetzner CX22 — €3.50/month (~$3.80 USD). 2 vCPU, 4 GB RAM, 40 GB SSD. This is the best value in VPS hosting, period. The catch: you need to verify account with payment method, and sometimes their verification system is slow. Worth the wait.
DigitalOcean Basic — $6/month. 1 vCPU, 1 GB RAM, 25 GB SSD. The simplest option if you want zero friction. Reliable, well-documented, easy to provision.
Vultr Cloud Compute — $6/month. Similar to DigitalOcean. Both are fine.
Ramnode — $5/month. 1 vCPU, 1 GB RAM, 20 GB SSD. Cheap and reliable, slightly less polished control panel.
For this guide, I’m going to use Hetzner because the price-to-performance ratio is genuinely unbeatable. But DigitalOcean or Vultr will work identically for this guide.
Step 1: Create and SSH Into Your VPS
After creating your VPS (Ubuntu 22.04 LTS), you’ll receive an IP address and root password by email. SSH in:
`bash
ssh root@your-vps-ip
`
You’ll be prompted to change the root password. Do it, then create a non-root user:
`bash
adduser deploy
usermod -aG sudo deploy
`
Set up SSH key-based auth (strongly recommended):
`bash
mkdir /home/deploy/.ssh
chmod 700 /home/deploy/.ssh
nano /home/deploy/.ssh/authorized_keys
Paste your public key, then:
chmod 600 /home/deploy/.ssh/authorized_keys
chown -R deploy:deploy /home/deploy/.ssh
`
Edit SSH config to disable password authentication:
`bash
sudo nano /etc/ssh/sshd_config
Find “PasswordAuthentication” and set it to “no”
Find “PermitRootLogin” and set it to “no”
sudo systemctl reload sshd
`
Log out and log back in as deploy from now on.
Step 2: Install Docker
`bash
sudo apt update && sudo apt upgrade -y
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker deploy
Log out and back in
exit
ssh deploy@your-vps-ip
docker –version
`
You should see Docker version 24.x or higher.
Step 3: Configure the Firewall
`bash
sudo ufw allow OpenSSH
sudo ufw allow http
sudo ufw allow https
sudo ufw enable
sudo ufw status
`
This allows SSH, HTTP, and HTTPS traffic while blocking everything else.
Step 4: Deploy OpenClaw with Docker Compose
`bash
mkdir openclaw && cd openclaw
`
Create docker-compose.yml:
`yaml
version: “3.9”
services:
openclaw:
image: openclaw/openclaw:latest
container_name: openclaw
restart: unless-stopped
ports:
– “127.0.0.1:18789:18789”
volumes:
– ./config:/root/.openclaw
– ./workspace:/root/.openclaw/workspace
environment:
– ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
– NODE_ENV=production
healthcheck:
test: [“CMD”, “curl”, “-f”, “http://localhost:18789/health”]
interval: 30s
timeout: 5s
retries: 3
start_period: 60s
`
Create the .env file with your API key:
`bash
echo “ANTHROPIC_API_KEY=sk-ant-your-key-here” > .env
chmod 600 .env
`
Start it:
`bash
docker compose up -d
`
Wait 30 seconds, then check:
`bash
docker compose logs –tail 20
`
You should see OpenClaw gateway running on :18789. If you see errors, wait another 30 seconds — sometimes the first startup takes a bit longer on a small VPS.
Step 5: Install Nginx and Configure HTTPS
Install Nginx:
`bash
sudo apt install -y nginx certbot python3-certbot-nginx
`
Configure Nginx:
`bash
sudo nano /etc/nginx/sites-available/openclaw
`
Paste:
`nginx
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://127.0.0.1:18789;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
`
Enable and get SSL:
`bash
sudo ln -s /etc/nginx/sites-available/openclaw /etc/nginx/sites-enabled/
sudo nginx -t
sudo certbot –nginx -d your-domain.com
`
If you don’t have a domain, skip the certbot step and access via http://your-vps-ip:18789 directly. Not recommended for production, but fine for testing.
Step 6: Connect a Messaging Platform
The easiest first platform is Telegram:
1. Message @BotFather on Telegram
2. Send /newbot, follow prompts, copy the token
3. Open https://your-domain.com in your browser
4. Go to Settings → Channels → Telegram → paste token → Save
5. Message your bot on Telegram
It should respond within seconds. If it doesn’t, check the logs:
`bash
docker compose logs | grep telegram
`
Step 7: Set Up Basic Monitoring
Install ctop for container monitoring:
`bash
sudo apt install -y ctop
ctop
`
For external monitoring, set up UptimeRobot’s free monitoring for https://your-domain.com/health. It checks every 5 minutes and alerts you if your site goes down.
Cost Breakdown
Here’s what you’re actually paying:
| Item | Cost |
|:—|—:|
| Hetzner CX22 VPS | €3.50/month |
| API key usage (moderate) | ~$5-10/month |
| Domain name (optional) | ~$10/year |
| Total | ~$9-15/month |
Compare to Claude Pro ($20/month) + separate costs for advanced features. The self-hosted path is meaningfully cheaper for power users, and you get full control.
When to Upgrade
The $5 VPS is fine for personal use with light to moderate message volume. You’ll want to upgrade when:
- Response times noticeably slow down during peak usage
- The container starts getting OOM (Out of Memory) kills
- You want to run multiple OpenClaw instances or add resource-intensive skills
The upgrade path is simple: stop the container, spin up a bigger VPS, copy the config directory, and restart. Zero downtime if you do it right.
The Bottom Line
A $5 VPS + OpenClaw + your own API key = a personal AI assistant that runs 24/7, connects to every messaging platform you use, costs less than most subscriptions, and gives you full privacy and control.
The setup takes 30 minutes. After that, it’s done. The official docs at docs.openclaw.ai have more advanced configuration options if you want to go deeper.
Start there. You won’t regret it.
Related Articles
Get Notified About New Articles
One email per week when I publish a new article or update an existing one. New AI tool reviews, deployment updates, behind-the-scenes notes. No marketing, no spam, unsubscribe in one click.
Or learn more · RSS feed
- How to Set Up Claude Code with the MiniMax API in 2026
- How to Set Up Hermes Web UI for AI Agent Management in 2026
- How to Self-Host n8n for $5/Month
- OpenClaw vs ChatGPT: Why Self-Hosting Wins for Power Users in 2026
Get Notified About New Articles
One email per week when I publish a new article or update an existing one. No marketing, no spam.