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:
- An always-on AI agent (Claude) running on your own server
- A web dashboard for chatting and managing your agent
- Telegram integration so you can message your agent from your phone
- A persistent workspace where your agent can read/write files, run commands, and manage projects
- Automatic restarts if the server reboots
What You'll Need
- A Hetzner account (sign up here)
- An Anthropic API key (get one here)
- A Telegram account (for the bot, optional but recommended)
- Basic comfort with the command line
- ~30 minutes
Step 1: Create Your Hetzner Server
Log into Hetzner Cloud Console and create a new server:
- Location: Pick the closest to you (I use Helsinki)
- Image: Ubuntu 24.04
- Type: CX22 (2 vCPU, 4GB RAM, 40GB disk) — €4.35/month
- SSH Key: Add your public key (or set a root password)
- Name: Whatever you want (mine is
openclaw-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
- Local or Remote: Choose Local (you're on the server)
- Port: Default
18789is fine - Bind: Choose
lanif you want remote access, orloopbackfor local only
Model Authentication
- Provider: Choose Anthropic
- API Key: Paste your Anthropic API key
- Default model:
claude-sonnet-4-5is the sweet spot for cost/quality. You can always change this later.
Channels
- Telegram: If you want Telegram integration (highly recommended), you'll need a bot token. More on this in Step 7.
- Skip other channels for now — you can add them later.
Daemon
- Install as service: Say yes. This creates a systemd service so OpenClaw starts automatically on boot and restarts if it crashes.
Gateway Token
- The wizard generates a security token. Save this somewhere safe — you'll need it to access the web dashboard.
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_IPand access vialocalhost: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
- Open Telegram and search for @BotFather
- Send
/newbot - Pick a name (e.g., "My AI Agent")
- Pick a username (e.g.,
my_ai_agent_bot) - 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:
- Get a free API key at brave.com/search/api
- 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
- Check the bot token is correct
- Check pairing is approved:
openclaw pairing list telegram - 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:
- Cron jobs: Schedule your agent to do things automatically (check emails, post to social media, run scrapers)
- Skills: Install community skills for GitHub, Google Workspace, image generation, and more
- Multi-agent setups: Spawn sub-agents for specific tasks
- Nodes: Connect your phone or laptop as a "node" so your agent can use your local screen, camera, and apps
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.
