Setting Up OpenClaw on a $5/Month VPS: Complete Guide
## Why Self-Host OpenClaw on a VPS?
Running OpenClaw on your own VPS gives you full control over your AI agent. No cloud vendor lock-in, no surprise bills, and your data stays yours. The best part? You can do it for just $5/month.
## Prerequisites
- A VPS from any provider (DigitalOcean, Hetzner, Vultr — all have $5/month plans)
- Ubuntu 22.04 or newer
- SSH access to your server
- Basic terminal knowledge
## Step 1: Provision Your VPS
Sign up for a VPS provider and create a droplet/instance with:
- **OS:** Ubuntu 22.04 LTS
- **RAM:** 1GB minimum (2GB recommended)
- **Storage:** 25GB SSD
- **Region:** Closest to you for low latency
## Step 2: Initial Server Setup
```bash
# SSH into your server
ssh root@your-server-ip
# Update packages
apt update && apt upgrade -y
# Create a non-root user
adduser openclaw
usermod -aG sudo openclaw
# Set up firewall
ufw allow OpenSSH
ufw allow 3000
ufw enable
```
## Step 3: Install Node.js
```bash
# Install Node.js 20 LTS
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
apt install -y nodejs
# Verify installation
node --version # Should show v20.x.x
npm --version
```
## Step 4: Install OpenClaw
```bash
# Install globally
npm install -g openclaw
# Initialize workspace
mkdir ~/.openclaw && cd ~/.openclaw
openclaw init
# Configure your AI provider
openclaw config set provider anthropic
openclaw config set apiKey your-api-key-here
```
## Step 5: Run as a Background Service
```bash
# Create a systemd service
sudo tee /etc/systemd/system/openclaw.service << 'EOF'
[Unit]
Description=OpenClaw AI Agent
After=network.target
[Service]
Type=simple
User=openclaw
ExecStart=/usr/bin/openclaw gateway start
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
# Enable and start
sudo systemctl enable openclaw
sudo systemctl start openclaw
sudo systemctl status openclaw
```
## Step 6: Secure Your Installation
1. **Set up SSL** with Let's Encrypt if exposing a web interface
2. **Configure authentication** in your OpenClaw config
3. **Keep updated:** `npm update -g openclaw` regularly
## Troubleshooting
**Port blocked?** Check `ufw status` and ensure port 3000 is allowed.
**Out of memory?** Add a 1GB swap file: `fallocate -l 1G /swapfile && mkswap /swapfile && swapon /swapfile`
**Service won't start?** Check logs: `journalctl -u openclaw -f`
## Next Steps
- [Hardening your agent server](/post/openclaw-security-best-practices-hardening-your-agent-server)
- [Building custom skills](/post/building-custom-skills-a-developers-guide-to-openclaw-extensions)
- [Automating Twitter](/post/automating-twitter-how-to-build-an-ai-social-media-manager-with-openclaw)
Your $5/month VPS is now a 24/7 AI agent. Not bad for the price of a coffee.