Hosting OpenClaw on a VPS — Complete Guide
Step-by-step guide to running OpenClaw on a VPS including setup, optimization, SSH configuration, troubleshooting disconnects, and best practices for Hetzner, DigitalOcean, Contabo, and Google Cloud.
⚠️ The Problem
🔍 Why This Happens
✅ The Fix
## VPS Requirements & Recommendations
Minimum specs:
- 1 vCPU, 1GB RAM, 500MB disk
Recommended:
- 2GB RAM (for logs, media processing, multiple channels)
- Ubuntu LTS (most tested platform)
Best practices:
- Run Gateway 24/7 — cron jobs won't fire if it sleeps
- Back up workspace (~/clawd) to a private git repo
- Keep state separate: ~/.clawdbot for config, ~/clawd for workspace
## Initial VPS Setup
``bash
# 1. Install Node.js 22+ (recommended method)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
# 2. Install OpenClaw
curl -fsSL https://clawd.bot/install.sh | bash
# 3. Run initial configuration
clawdbot configure
# 4. Start the gateway
clawdbot gateway start
## Fixing Interrupted Setup (RPi / VPS) If setup was cancelled or interrupted and you get 'command not found':
# Create config directory if missingmkdir -p ~/.config/clawdbot# Re-run configuration wizardclawdbot configure# If clawdbot command not found, reinstallcurl -fsSL https://clawd.bot/install.sh | bashFor Raspberry Pi specifically: - Ensure you're using arm64-compatible models if running local LLMs - Cloud API models (OpenAI, Anthropic, OpenRouter) work on all architectures
## Fixing WebSocket Disconnect (1006) on Hetzner/Cloud VPS
# 1. Check if gateway is runningclawdbot gateway status# 2. If not running, start itclawdbot gateway start# 3. Check logs for detailsclawdbot gateway logsCommon causes on cloud VPS: - Gateway process not running - Token mismatch between config and environment - Discord rate-limiting cloud IPs (try VPN temporarily) - Resource exhaustion
# Check resourcesfree -hdf -h# Restart gatewayclawdbot gateway restart## Gateway Token Configuration
Important: The dashboard uses gateway.auth.token, NOT gateway.token.
# Check current tokenclawdbot config get gateway.auth.token# Set a token if emptyclawdbot config set gateway.auth.token "your-secure-random-token"# Or use environment variableexport CLAWDBOT_GATEWAY_TOKEN="your-token-here"# Restart after changesclawdbot gateway restartToken location summary:
- ❌ gateway.token — ignored
- ✅ gateway.auth.token — used by dashboard
- ✅ CLAWDBOT_GATEWAY_TOKEN env var — also works
## Connecting Local OpenClaw to Remote VPS via SSH To have OpenClaw on your local machine control a remote VPS:
# 1. Generate SSH key if you don't have onessh-keygen -t ed25519 -C "openclaw-vps"# 2. Copy public key to VPSssh-copy-id user@your-vps-ip# 3. Test connection manually firstssh user@your-vps-ip# 4. Configure OpenClaw to use SSH# Add to your TOOLS.md or workspace config:# SSH: user@your-vps-ip for web server managementFor Contabo/DigitalOcean/Hetzner: - Ensure SSH is enabled in your VPS control panel - Check firewall allows port 22 - Use key-based auth (more reliable than passwords)
## Installing Skills on Linux VPS ClawdHub UI isn't available on headless Linux. Use CLI:
# Install ClawdHub CLInpm i -g clawdhub# orpnpm add -g clawdhub# Search for skillsclawdhub search "web search"# Install a skillclawdhub install skill-slug# Update all skillsclawdhub update --allIf ClawdHub isn't working, install manually:
# Create skills foldermkdir -p ~/clawd/skills# Clone skills repositorygit clone https://github.com/clawdbot/clawdbot.git ~/clawd-skillscp -r ~/clawd-skills/skills/* ~/clawd/skills/# Configure workspace skills directoryclawdbot config set skills.dir ~/clawd/skills# Restart to loadclawdbot gateway restart## Accessing the Gateway Dashboard The web dashboard shows gateway status and connected clients.
# Get dashboard URLclawdbot gateway status# Default: http://localhost:3333 (or configured port)# For remote access, use SSH tunnel:ssh -L 3333:localhost:3333 user@your-vps-ip# Then access http://localhost:3333 in your browserFor public access (not recommended without auth):
- Set up nginx/caddy reverse proxy
- Add SSL certificate (Let's Encrypt)
- Configure gateway.auth.token for protection
## Uninstalling OpenClaw on Linux The docs may be missing this command:
# For openclaw packagenpm uninstall -g openclaw# For clawdbot packagenpm uninstall -g clawdbot# orpnpm remove -g clawdbot# Remove config and datarm -rf ~/.clawdbotrm -rf ~/.config/clawdbot## Running Gateway as a Service (Systemd) For production VPS, run as a systemd service:
# Create service filesudo nano /etc/systemd/system/clawdbot.service[Unit]Description=Clawdbot GatewayAfter=network.target[Service]Type=simpleUser=your-usernameWorkingDirectory=/home/your-usernameExecStart=/usr/bin/clawdbot gateway start --foregroundRestart=alwaysRestartSec=10Environment=NODE_ENV=production[Install]WantedBy=multi-user.target# Enable and start servicesudo systemctl daemon-reloadsudo systemctl enable clawdbotsudo systemctl start clawdbot# Check statussudo systemctl status clawdbot# View logsjournalctl -u clawdbot -f## Discord Moderation on VPS OpenClaw has basic moderation capabilities: Supported: - ✅ React to messages, pin/unpin - ✅ Search message history, create threads - ✅ Manage channels, roles, categories - ✅ Kick/ban users via API Not built-in: - ❌ Auto-moderation (spam detection) - ❌ Automated warnings/mutes - ❌ Anti-raid protection - ❌ Custom mod logs For full moderation, integrate dedicated bots alongside OpenClaw.
🔥 Your AI should run your business, not just answer questions.
We'll show you how.$97/mo (going to $197 soon)
📋 Quick Commands
| Command | Description |
|---|---|
| clawdbot gateway start | Start the gateway daemon |
| clawdbot gateway status | Check gateway status and dashboard URL |
| clawdbot gateway logs | View gateway logs for debugging |
| clawdbot gateway restart | Restart gateway (fixes many issues) |
| clawdbot configure | Run setup wizard (use after interrupted install) |
| clawdbot config set gateway.auth.token TOKEN | Set dashboard authentication token |
| clawdbot config get gateway.auth.token | Check current gateway token |
| npm uninstall -g openclaw | Uninstall openclaw package (legacy) |
| npm uninstall -g clawdbot | Uninstall clawdbot package |
| ssh-copy-id user@vps-ip | Copy SSH key to VPS for passwordless access |
| clawdhub search QUERY | Search for skills (Linux CLI) |
| clawdhub install SKILL | Install a skill on Linux VPS |
| sudo systemctl status clawdbot | Check systemd service status |
Related Issues
📚 You Might Also Like
How to Set Up OpenClaw on Mac Mini (Perfect Always-On Setup)
The ideal dedicated AI assistant setup. Buy once, runs forever, no monthly fees for hosting.
Self-Hosted AI Assistant: The Complete 2026 Guide
Want complete control over your AI assistant? Self-hosting means your data stays on your hardware, your conversations remain private, and you can customize everything. This guide covers it all.
How to Deploy OpenClaw on Hostinger VPS (Step-by-Step Guide)
Set up your own 24/7 AI assistant on Hostinger VPS with one-click deployment. Connect Telegram, configure your LLM, and add skills.
How to Self-Host Your Own AI Assistant
Complete technical guide to self-hosting an AI assistant. Choose your hardware, configure your server, and keep your data 100% private.
🐙 Your AI should run your business.
Weekly live builds + template vault. We'll show you how to make AI actually work.$97/mo (going to $197 soon)
Join Vibe Combinator →