Back to blog
How to Set Up OpenClaw on a Hetzner VPS — Complete Guide
OpenClawHetznerVPSAI AgentSelf-HostingTutorial

How to Set Up OpenClaw on a Hetzner VPS — Complete Guide

A step-by-step guide to running your own AI agent 24/7 on a €4/month Hetzner server. From zero to a fully working OpenClaw setup with Telegram, web dashboard, and always-on AI assistant.

8 min read

How to Set Up OpenClaw on a Hetzner VPS — Complete Guide

Want your own AI agent running 24/7 for less than the price of a coffee? This guide walks you through setting up OpenClaw on a Hetzner VPS from scratch. No Docker needed — just a clean Linux server, Node.js, and about 30 minutes.

I've been running this exact setup for months. It handles my projects, monitors my services, manages social media, and responds to messages on Telegram around the clock. Here's exactly how to replicate it.

What You'll Get

By the end of this guide, you'll have:

What You'll Need

Step 1: Create Your Hetzner Server

Log into Hetzner Cloud Console and create a new server:

The CX22 is plenty for OpenClaw. It uses about 1-1.5GB RAM idle, so 4GB gives you comfortable headroom for running scripts, scrapers, and builds alongside the agent.

Click Create & Buy. Your server will be ready in about 30 seconds.

Step 2: Connect and Update

SSH into your fresh server:

ssh root@YOUR_SERVER_IP

Update everything:

apt update && apt upgrade -y

Step 3: Install Node.js 22+

OpenClaw requires Node.js 22 or later. The easiest way on Ubuntu:

curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt install -y nodejs

Verify:

node -v  # Should show v22.x.x
npm -v   # Should show 10.x.x

Step 4: Install OpenClaw

One command:

npm install -g openclaw@latest

Verify it's installed:

openclaw --version

You should see the version number. If you get "command not found", the npm global bin directory isn't on your PATH. Fix it with:

export PATH="$(npm prefix -g)/bin:$PATH"
echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.bashrc

Step 5: Run the Onboarding Wizard

This is where the magic happens. The wizard walks you through everything:

openclaw onboard --install-daemon

You'll be asked several things:

Gateway Setup

Model Authentication

Channels

Daemon

Gateway Token

Step 6: Verify It's Running

Check the service status:

openclaw gateway status

You should see it's running. You can also check:

openclaw status
openclaw health

The web dashboard is now available at http://YOUR_SERVER_IP:18789/. You'll need the gateway token from the wizard to log in.

Security note: If your gateway is bound to lan, anyone who knows your IP and token can access it. For production use, either:

  • Use an SSH tunnel: ssh -N -L 18789:127.0.0.1:18789 root@YOUR_SERVER_IP and access via localhost:18789
  • Set up Tailscale for private networking
  • Use a reverse proxy with HTTPS

Step 7: Set Up Telegram (Recommended)

Telegram is the best way to talk to your agent from your phone. Here's how:

Create a Telegram Bot

  1. Open Telegram and search for @BotFather
  2. Send /newbot
  3. Pick a name (e.g., "My AI Agent")
  4. Pick a username (e.g., my_ai_agent_bot)
  5. BotFather gives you a token — copy it

Add it to OpenClaw

Edit your OpenClaw config:

openclaw configure --section telegram

Or manually edit ~/.openclaw/openclaw.json:

{
  "channels": {
    "telegram": {
      "enabled": true,
      "token": "YOUR_BOT_TOKEN_HERE"
    }
  }
}

Restart the gateway:

openclaw gateway restart

First Message

Open your bot in Telegram and send a message. The first time, you'll get a pairing code. Approve it:

openclaw pairing list telegram
openclaw pairing approve telegram YOUR_CODE

Now you can message your agent anytime, anywhere. It's like having a developer on call 24/7.

Step 8: Add Web Search (Optional but Recommended)

Give your agent the ability to search the web with a Brave Search API key:

  1. Get a free API key at brave.com/search/api
  2. Add it to your config:
openclaw configure --section web

This lets your agent look things up, check documentation, and stay current on information.

Step 9: Set Up Your Workspace

Your agent's workspace lives at ~/.openclaw/workspace/. This is where it stores files, code, and project data. You can:

cd ~/.openclaw/workspace
git clone https://github.com/your/project.git

Now your agent can read and work on your codebase directly.

Pro tip: Create an AGENTS.md

Create ~/.openclaw/workspace/AGENTS.md with instructions for your agent — what projects you're working on, your preferences, how you like things done. The agent reads this at the start of every session.

Pro tip: Create a SOUL.md

Create ~/.openclaw/workspace/SOUL.md to define your agent's personality. Want it casual? Professional? Funny? This is where you set the vibe.

Step 10: Install Useful Tools

Some tools make the agent much more capable:

# Git (usually pre-installed)
apt install -y git

# Build essentials (for npm packages with native deps)
apt install -y build-essential

# Python + uv (for AI image generation and other Python tools)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Chromium + Playwright (if you want web scraping)
npx playwright install --with-deps chromium

Keeping It Updated

OpenClaw updates frequently. To update:

openclaw update

Or manually:

npm install -g openclaw@latest
openclaw gateway restart

Cost Breakdown

Here's what this setup actually costs per month:

| Item | Cost | |------|------| | Hetzner CX22 | €4.35/mo | | Anthropic API (depends on usage) | ~$5-30/mo | | Brave Search API (free tier) | $0 | | Total | ~€10-35/mo |

The Anthropic API cost depends entirely on how much you use it. Light usage (a few chats a day) might be $5/month. Heavy usage with code generation and long conversations could be $30+. You can monitor your usage with openclaw status.

Troubleshooting

"openclaw: command not found"

export PATH="$(npm prefix -g)/bin:$PATH"

Gateway won't start

openclaw gateway --verbose  # Run in foreground to see errors
journalctl -u openclaw-gateway -f  # Check systemd logs

Telegram bot not responding

  1. Check the bot token is correct
  2. Check pairing is approved: openclaw pairing list telegram
  3. Restart: openclaw gateway restart

High memory usage

The CX22 has 4GB. If you're running other services too, watch memory:

free -h
htop

Server rebooted and agent is down

If you installed the daemon during onboarding, it should auto-start. If not:

openclaw gateway start

What's Next

Once you're up and running, explore:

The beauty of this setup is that it grows with you. Start with a simple chat bot, and gradually give it more responsibilities as you build trust in the workflow.


Running into issues? The OpenClaw Discord is genuinely helpful, and the docs are comprehensive. Or just ask your agent to help debug itself — it's surprisingly good at that.

Back to all posts