Lesson 5. Server Deployment (24/7)#

Why You Need This#

If OpenClaw runs on your laptop, it shuts down when you close the lid. To keep your assistant available around the clock, you need to run it on a server — a computer that’s always on. This can be a rented cloud server for about $5/month.

Deployment Options#

Option Difficulty Cost Best For
Hetzner VPS + Docker Medium ~$5/mo Most popular option
Fly.io Low ~$5/mo Quick start without SSH
Any VPS Medium $3-10/mo DigitalOcean, Oracle, etc.
Home server High $0 Raspberry Pi, old PC

What You Need#

  • An account at hetzner.com
  • Basic familiarity with the terminal
  • ~20 minutes

Step 1. Rent a Server#

On Hetzner, choose the cheapest VPS with Ubuntu or Debian. The minimum configuration will do.

Step 2. Connect via SSH#

SSH (Secure Shell) is a way to remotely control a server through the terminal.

ssh root@your-ip-address

Step 3. Install Docker#

Docker is a program for running applications in isolated containers.

apt update && apt install -y docker.io docker-compose-v2

Step 4. Download OpenClaw#

git clone https://github.com/openclaw/openclaw.git
cd openclaw

Step 5. Run the Setup#

./docker-setup.sh

The script will automatically:

  • Build the Docker image
  • Launch the initial setup wizard
  • Create a token for secure access
  • Start the Gateway

Step 6. Verify It Works#

docker compose exec openclaw-gateway node dist/index.js health --token "$OPENCLAW_GATEWAY_TOKEN"

Step 7. Browser Access#

Create an SSH tunnel from your laptop:

ssh -N -L 18789:127.0.0.1:18789 root@your-ip-address

Now open http://127.0.0.1:18789/ in your browser — you’ll see the control panel.

Option 2: Fly.io#

Fly.io is a cloud platform that simplifies deployment. No need to configure a server manually.

Step 1. Install flyctl#

curl -L https://fly.io/install.sh | sh

Step 2. Create an App#

git clone https://github.com/openclaw/openclaw.git
cd openclaw

fly apps create my-openclaw
fly volumes create openclaw_data --size 1 --region iad

Step 3. Set Secrets#

fly secrets set ANTHROPIC_API_KEY=your-key
fly secrets set OPENCLAW_GATEWAY_TOKEN=your-token
fly secrets set TELEGRAM_BOT_TOKEN=your-bot-token

Step 4. Deploy#

fly deploy

Fly.io will automatically:

  • Build the image
  • Deploy it to a server
  • Set up HTTPS
  • Restart on failures

Option 3: Any VPS with Docker#

General steps for any VPS provider (DigitalOcean, Oracle, Vultr, etc.):

  1. Rent a server with Ubuntu/Debian
  2. Install Docker
  3. Clone the OpenClaw repository
  4. Run ./docker-setup.sh
  5. Set up auto-restart (Docker Compose handles this automatically)

Important Server Settings#

Data Storage#

All OpenClaw data is stored in ~/.openclaw/. Make sure this folder is on a persistent disk (not temporary storage).

When using Docker, data is mounted from the host:

volumes:
  - ~/.openclaw:/home/node/.openclaw
  - ~/.openclaw/workspace:/home/node/.openclaw/workspace

Configuring Channels in Docker#

# WhatsApp (QR code)
docker compose run --rm openclaw-cli channels login

# Telegram
docker compose run --rm openclaw-cli channels add --channel telegram --token "your-token"

# Discord
docker compose run --rm openclaw-cli channels add --channel discord --token "your-token"

File Permissions#

The OpenClaw Docker image runs as the node user (uid 1000). If you see permission errors:

sudo chown -R 1000:1000 ~/.openclaw

Additional Packages#

If you need system programs inside the container:

export OPENCLAW_DOCKER_APT_PACKAGES="ffmpeg git curl"
./docker-setup.sh

Automatic Restart#

Docker Compose automatically restarts the container on failure. To start on server boot:

systemctl enable docker

To check:

docker compose ps
docker compose logs --tail 50

Lesson Summary#

  • To run 24/7, deploy OpenClaw on a server (VPS)
  • Hetzner + Docker — the most popular and affordable option (~$5/mo)
  • Fly.io — the easiest option with no server setup
  • Use ./docker-setup.sh for automatic configuration
  • Data is stored in ~/.openclaw/ — don’t forget backups
  • SSH tunnels let you securely manage the server from your browser