Guide
How to Deploy OpenClaw on a VPS
Self-host your OpenClaw AI agent on a VPS with Docker — full control over your deployment.
Why Self-Host on a VPS?
Running OpenClaw on your own VPS gives you full control over your AI agent. Your data stays on your server, you can customize everything, and you're not dependent on any third-party platform. However, self-hosting requires technical knowledge and ongoing maintenance — you're responsible for updates, security patches, backups, and uptime.
Choosing a VPS Provider
OpenClaw runs on any Linux VPS with Docker support. Here are popular options:
| Provider | Starting Price | Highlights | Locations |
|---|---|---|---|
| Hetzner | $4/mo | Best value | EU & US |
| DigitalOcean | $6/mo | Great documentation | Global |
| Vultr | $6/mo | Many locations | Global |
| Linode | $5/mo | Solid performance | Global |
Step 1: Set Up Your VPS
After provisioning your VPS, SSH in and install Docker:
ssh root@your-server-ip
# Update packages
apt update && apt upgrade -y
# Install Docker
curl -fsSL https://get.docker.com | sh
# Verify Docker is running
docker --versionStep 2: Install OpenClaw
Pull the OpenClaw Docker image and create the config directory:
# Pull the latest OpenClaw image
docker pull ghcr.io/openclaw/openclaw:latest
# Create the config directory
mkdir -p ~/openclaw/credentials
chmod 777 ~/openclaw
chmod 777 ~/openclaw/credentialsThe container runs as user node (uid 1000). The config directory needs chmod 777 because the host user and container user differ. The credentials/ subdirectory is required for DM pairing to work.
Step 3: Configure OpenClaw
Create ~/openclaw/openclaw.json with your settings:
{
"gateway": {
"port": 18789,
"auth": { "token": "your-random-secret-token" }
},
"models": {
"providers": {
"openrouter": {
"apiKey": "sk-or-your-api-key"
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "openrouter/anthropic/claude-sonnet-4.6"
},
"systemPrompt": "You are a helpful AI assistant."
}
},
"channels": {
"telegram": {
"enabled": true,
"botToken": "123456:ABC-your-bot-token",
"dmPolicy": "pairing"
},
"discord": {
"enabled": true,
"botToken": "your-discord-bot-token",
"dmPolicy": "open",
"allowFrom": ["*"]
}
},
"plugins": {
"entries": {
"telegram": { "enabled": true },
"discord": { "enabled": true }
}
}
}gateway.auth field must be an object with a token property — not a plain string. Both channels.X.enabled and plugins.entries.X.enabled must be true for a channel to work. Model IDs must be prefixed with the provider name (e.g. openrouter/anthropic/claude-sonnet-4.6).Step 4: Run the Container
docker run -d \
--name openclaw \
--restart unless-stopped \
--memory=2g --memory-swap=3g \
-v ~/openclaw:/home/node/.openclaw \
-p 18789:18789 \
ghcr.io/openclaw/openclaw:latest \
node openclaw.mjs gateway --allow-unconfiguredKey flags explained:
--memory=2g --memory-swap=3g— OpenClaw needs at least 2 GB RAM. Running with 512 MB causes OOM crashes.-v ~/openclaw:/home/node/.openclaw— Bind-mounts your config directory into the container.-p 18789:18789— Exposes the web gateway port.--restart unless-stopped— Auto-restarts after crashes or server reboots.
Step 5: Set Up a Reverse Proxy (Optional)
To access the OpenClaw gateway over HTTPS with a custom domain, set up Caddy as a reverse proxy. Caddy handles automatic SSL certificate provisioning and renewal.
# Install Caddy
apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt update && apt install caddyCreate a Caddyfile at /etc/caddy/Caddyfile:
your-domain.com {
reverse_proxy localhost:18789
}Restart Caddy with systemctl restart caddy. It will automatically obtain and renew an SSL certificate for your domain.
Maintenance Considerations
Self-hosting means you're responsible for everything:
- Updates: Periodically pull the latest image and restart —
docker pull ghcr.io/openclaw/openclaw:latest, then recreate the container. - Backups: Back up your
~/openclawdirectory regularly. This contains your config, credentials, and session data. - Monitoring: Set up uptime monitoring to detect outages. Check
docker logs openclawfor errors. - Security patches: Keep your VPS OS updated with
apt update && apt upgrade. Enable automatic security updates. - SSL renewal: If using Caddy, this is automatic. With other reverse proxies, ensure certificates renew before expiry.
VPS vs OpenClaw Launch
Not sure if self-hosting is right for you? Here's how it compares:
| VPS (Self-Hosted) | OpenClaw Launch | |
|---|---|---|
| Setup time | 2-6 hours | 30 seconds |
| Cost | $5-20/mo + your time | $3/mo |
| Maintenance | Manual (updates, backups, monitoring) | Fully managed |
| Visual config | No — edit JSON manually | Yes — point-and-click configurator |
| Skills | Manual install | Built-in browser & tools |
| Updates | Manual docker pull + restart | Automatic |
Next Steps
For a more detailed walkthrough of the installation process, including troubleshooting tips and platform-specific instructions, see the complete OpenClaw install guide.