← Home

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:

ProviderStarting PriceHighlightsLocations
Hetzner$4/moBest valueEU & US
DigitalOcean$6/moGreat documentationGlobal
Vultr$6/moMany locationsGlobal
Linode$5/moSolid performanceGlobal
Minimum specs: 2 vCPU, 4 GB RAM. OpenClaw needs at least 2 GB RAM per container, plus overhead for the OS and Docker itself.

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 --version

Step 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/credentials

The 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 }
    }
  }
}
Important: The 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-unconfigured

Key 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 caddy

Create 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 ~/openclaw directory regularly. This contains your config, credentials, and session data.
  • Monitoring: Set up uptime monitoring to detect outages. Check docker logs openclaw for 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 time2-6 hours30 seconds
Cost$5-20/mo + your time$3/mo
MaintenanceManual (updates, backups, monitoring)Fully managed
Visual configNo — edit JSON manuallyYes — point-and-click configurator
SkillsManual installBuilt-in browser & tools
UpdatesManual docker pull + restartAutomatic

Next Steps

For a more detailed walkthrough of the installation process, including troubleshooting tips and platform-specific instructions, see the complete OpenClaw install guide.

Skip the VPS — Deploy in 30 Seconds

Don't want to manage servers? OpenClaw Launch handles everything for you.

Configure & Deploy