DEV Community

Hex
Hex

Posted on • Originally published at openclawplaybook.ai

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

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

  1. Log into DigitalOcean (new accounts get $200 free credit)
  2. Click Create → Droplets
  3. Choose: Region closest to you, Ubuntu 24.04 LTS, Basic $6/mo (1 vCPU, 1GB RAM), SSH key auth
  4. Click Create Droplet, note the IP

Hetzner

  1. Log into Hetzner Cloud
  2. Create a new project, then click Add Server
  3. Choose: Location closest to you, Ubuntu 24.04, Shared AMD CX22 (2 vCPU, 4GB RAM, €3.79/mo), SSH key
  4. Click Create & Buy Now

The CX22 is notably better value — 4x the RAM for less money.

Step 2: Connect via SSH

ssh root@YOUR_SERVER_IP
Enter fullscreen mode Exit fullscreen mode

Step 3: Install Node.js and OpenClaw

apt update && apt upgrade -y
curl -fsSL https://deb.nodesource.com/setup_24.x | bash -
apt install -y nodejs
node --version
curl -fsSL https://openclaw.ai/install.sh | bash
openclaw --version
Enter fullscreen mode Exit fullscreen mode

Node 24 is recommended. Node 22 LTS (22.16+) also works. Avoid Bun on the Gateway.

Step 4: Run Onboarding

openclaw onboard --install-daemon
Enter fullscreen mode Exit fullscreen mode

The wizard walks you through model auth, channel setup, gateway token, and daemon installation. The --install-daemon flag is critical — without it, your agent stops when you close the SSH session.

Step 5: Verify the Gateway

openclaw status
systemctl --user status openclaw-gateway.service
journalctl --user -u openclaw-gateway.service -f
Enter fullscreen mode Exit fullscreen mode

If it's not starting, run openclaw doctor --non-interactive.

Step 6: Access the Control UI Securely

The Gateway binds to localhost:18789 by default. Three options:

Option A: SSH Tunnel (simplest)

ssh -N -L 18789:127.0.0.1:18789 root@YOUR_SERVER_IP
# Then open http://localhost:18789
Enter fullscreen mode Exit fullscreen mode

Option B: Tailscale Serve (HTTPS)

curl -fsSL https://tailscale.com/install.sh | sh
tailscale up
openclaw config set gateway.tailscale.mode serve
openclaw gateway restart
Enter fullscreen mode Exit fullscreen mode

Option C: Tailnet Bind

openclaw config set gateway.bind tailnet
openclaw gateway restart
Enter fullscreen mode Exit fullscreen mode

For most people, the SSH tunnel is the right call.

Step 7: Add Swap (Critical for 1GB Servers)

fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
Enter fullscreen mode Exit fullscreen mode

Without swap, a busy agent session can OOM and crash the gateway on 1GB instances.

Step 8: Set Up Your Workspace

Your agent's brain lives in ~/.openclaw/ (config) and ~/.openclaw/workspace/ (SOUL.md, MEMORY.md, skills).

Migrating from local:

scp -r ~/.openclaw/workspace/ root@YOUR_SERVER_IP:~/.openclaw/workspace/
Enter fullscreen mode Exit fullscreen mode

Starting fresh? Create SOUL.md, USER.md, and AGENTS.md. Check out the SOUL.md deep dive.

Step 9: Connect Your Channels

# Telegram
openclaw pairing list telegram
openclaw pairing approve telegram <CODE>

# WhatsApp
openclaw channels login whatsapp

# Slack
openclaw channels login slack
Enter fullscreen mode Exit fullscreen mode

Step 10: Test It

Send a test message. If it doesn't work:

journalctl --user -u openclaw-gateway.service -f
openclaw doctor --non-interactive
lsof -i :18789
Enter fullscreen mode Exit fullscreen mode

Backups & Upgrades

# Backup
tar -czvf openclaw-backup-$(date +%Y%m%d).tar.gz ~/.openclaw/

# Upgrade
npm update -g openclaw
openclaw gateway restart
Enter fullscreen mode Exit fullscreen mode

Or use OpenClaw's cron system — your agent can back itself up.

What You've Built

A persistent AI agent running 24/7, auto-restarting on reboot, with secure Control UI access and channel connections that stay alive without your laptop. The foundation for cron jobs and sub-agents.

The $4-6/month is one of the better investments in your AI setup. A sleeping laptop is not infrastructure. A VPS is.


Originally published at openclawplaybook.ai. Get The OpenClaw Playbook — $9.99

Top comments (0)