How to Deploy OpenClaw on a VPS (DigitalOcean/Hetzner Guide)
Running OpenClaw on your laptop is fine for testing. But if you want your AI agent available 24/7 — responding to Slack messages at 3am, firing cron jobs while you sleep, staying connected to all your channels without your laptop needing to be on — you need a VPS.
The good news: a capable OpenClaw server costs as little as $4/month. This guide covers the full setup on DigitalOcean and Hetzner, two of the most reliable options, plus the key Linux configuration steps that most guides skip.
Why a VPS?
Your laptop goes to sleep. Your home internet goes down. Local OpenClaw setups are fine for daytime use, but they're not infrastructure. A VPS gives you:
- Always-on availability: Agent responds 24/7, even when you're offline
- Reliable channel connections: WhatsApp, Telegram, Discord stay connected without interruption
- Cron jobs that actually fire: Scheduled tasks run on time, every time
- Separation from your dev machine: No more "wait let me open my laptop" to ask your agent something
The tradeoff is a monthly cost and some initial setup. Neither is a big deal.
Picking a Provider
Here's a quick comparison of the most common choices:
| Provider | Plan | Specs | Price/mo | Notes |
|---|---|---|---|---|
| Hetzner | CX22 | 2 vCPU, 4GB RAM | ~€3.79 (~$4) | Best value. European data centers, excellent uptime. |
| DigitalOcean | Basic | 1 vCPU, 1GB RAM | $6 | Easiest UX. Good docs. US/EU/Asia regions. |
| Oracle Cloud | Always Free ARM | 4 OCPU, 24GB RAM | $0 | Best specs, but signup is finicky. ARM-only. |
| Vultr | Cloud Compute | 1 vCPU, 1GB RAM | $6 | Good global coverage. |
My recommendation: Hetzner if you want the best value, DigitalOcean if you want the easiest setup experience. Both work identically once Node is installed — everything from Step 3 onward is the same.
If you want free, Oracle Cloud is genuinely incredible specs-wise, but the signup flow can be painful. Worth trying if you have patience.
Step 1: Create Your Server
DigitalOcean
- Log into DigitalOcean (new accounts get $200 free credit)
- Click Create → Droplets
- Choose:
- Region: Closest to you
- Image: Ubuntu 24.04 LTS
- Size: Basic → Regular → $6/mo (1 vCPU, 1GB RAM)
- Auth: SSH key (strongly recommended over password)
- Click Create Droplet, note the IP
Hetzner
- Log into Hetzner Cloud
- Create a new project, then click Add Server
- Choose:
- Location: Closest to you (Nuremberg, Helsinki, Ashburn)
- Image: Ubuntu 24.04
- Type: Shared AMD → CX22 (2 vCPU, 4GB RAM, €3.79/mo)
- SSH key: Add yours
- Click Create & Buy Now
The CX22 is notably better value than DigitalOcean's $6 droplet — 4x the RAM for less money. If you're choosing fresh, Hetzner wins.
Step 2: Connect via SSH
ssh root@YOUR_SERVER_IP If you used an SSH key, you'll be in immediately. If you used a password, you'll be prompted. Either way, you're now on your server.
Step 3: Install Node.js and OpenClaw
# Update the system first
apt update && apt upgrade -y
# Install Node.js 24 (recommended)
curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
apt install -y nodejs
# Verify Node is working
node --version
# Install OpenClaw globally
curl -fsSL https://openclaw.ai/install.sh | bash
# Verify
openclaw --version Node 24 is the recommended runtime. Node 22 LTS (22.16+) also works. Avoid Bun on the Gateway — it has known issues with WhatsApp and Telegram.
Step 4: Run Onboarding
openclaw onboard --install-daemon The wizard walks you through:
- Model auth — your API keys (Claude, GPT, etc.)
- Channel setup — Telegram, WhatsApp, Discord, or whatever you use
- Gateway token — auto-generated, used to authenticate the Control UI
- Daemon installation — installs a systemd service so the Gateway starts automatically on reboot
The --install-daemon flag is important. Without it, your agent stops when you close the SSH session. With it, it runs as a systemd user service that survives reboots.
Step 5: Verify the Gateway
# Check overall status
openclaw status
# Check the systemd service
systemctl --user status openclaw-gateway.service
# Tail logs
journalctl --user -u openclaw-gateway.service -f If the service is active and you see "Gateway listening" in the logs, you're good. If it's not starting, run openclaw doctor --non-interactive — it diagnoses common issues automatically.
Step 6: Access the Control UI Securely
The Gateway binds to localhost:18789 by default. You can't hit it directly from a browser since it's not exposed to the internet (which is correct — you don't want it public).
There are three options:
Option A: SSH Tunnel (simplest)
# Run this from your local machine
ssh -N -L 18789:127.0.0.1:18789 root@YOUR_SERVER_IP
# Then open in your browser:
# http://localhost:18789 This forwards port 18789 from the server to your local machine through the SSH connection. No firewall rules needed. Most secure option.
Option B: Tailscale Serve (cleaner, HTTPS)
# On the server
curl -fsSL https://tailscale.com/install.sh | sh
tailscale up
# Configure Gateway to use Tailscale Serve
openclaw config set gateway.tailscale.mode serve
openclaw gateway restart Tailscale Serve gives you a stable HTTPS URL within your tailnet and handles auth via Tailscale identity headers. Good if you have multiple devices you want to access the Control UI from.
Option C: Tailnet Bind (direct access)
openclaw config set gateway.bind tailnet
openclaw gateway restart
# Access via:
# http://<tailscale-ip>:18789 Binds the Gateway directly to your Tailscale IP. Requires your token to access. Good if you just want Tailscale access without the Serve proxy layer.
For most people, the SSH tunnel (Option A) is the right call. It requires nothing extra and just works.
Step 7: Add Swap (Critical for 1GB Servers)
If you're on DigitalOcean's $6 droplet or similar 1GB RAM instances, you need swap. Without it, a busy agent session can OOM and crash the gateway.
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab This adds 2GB of swap and makes it persistent across reboots. On Hetzner's CX22 with 4GB RAM, swap is less critical but still worth adding for peace of mind.
Check memory anytime with:
free -h
# or
htop Step 8: Set Up Your Workspace
Your agent's brain lives in two directories:
~/.openclaw/— config, credentials, session data, cron jobs~/.openclaw/workspace/— SOUL.md, MEMORY.md, skills, everything your agent reads
If you're migrating from a local setup, copy your workspace over:
# From your local machine
scp -r ~/.openclaw/workspace/ root@YOUR_SERVER_IP:~/.openclaw/workspace/ If you're starting fresh, run through the standard setup: create SOUL.md, USER.md, and AGENTS.md in your workspace. These are what give your agent context about who it is and what it's working on. Check out our SOUL.md deep dive if you haven't done this yet.
Step 9: Connect Your Channels
With the gateway running, connect whatever channels you use:
Telegram
openclaw pairing list telegram
openclaw pairing approve telegram <CODE> openclaw channels login whatsapp
# Scan the QR code that appears Slack
Slack uses OAuth. Run openclaw channels login slack and follow the browser flow. If you're on a headless server, you can use the SSH tunnel to the Control UI at localhost:18789 to complete the OAuth flow.
Step 10: Test the Setup
Send a test message through whichever channel you connected. The agent should respond. If it doesn't:
# Check gateway logs
journalctl --user -u openclaw-gateway.service -f
# Run doctor
openclaw doctor --non-interactive
# Check if port is in use
lsof -i :18789 Backups
Set up a periodic backup of your OpenClaw state. All the important stuff lives in ~/.openclaw/:
tar -czvf openclaw-backup-$(date +%Y%m%d).tar.gz ~/.openclaw/ Run this with a cron job, or better yet — use OpenClaw's own cron system to schedule it. Your agent can back itself up.
Upgrading OpenClaw
npm update -g openclaw
# Restart the gateway to pick up the new version
openclaw gateway restart The gateway checks for updates and will often prompt you via chat if one is available.
What You've Built
At this point you have:
- A persistent AI agent running 24/7 on a cloud server
- Auto-restart on reboot via systemd
- Secure Control UI access via SSH tunnel or Tailscale
- Channel connections that stay alive without your laptop
- The foundation for cron jobs, sub-agents, and autonomous workflows
From here, the next step is usually adding cron jobs to automate recurring tasks, or setting up sub-agents to delegate work. Both become significantly more useful with a 24/7 server backing them.
The $4-6/month is one of the better investments in your AI setup. A sleeping laptop is not infrastructure. A VPS is.
Want the complete guide? Get The OpenClaw Playbook — $9.99