Setup Guide

How to Set Up OpenClaw on Hetzner (Complete Guide)

From zero to a running AI agent in under 30 minutes.

Every step explained for absolute beginners. No experience required — just follow along.

By Johann Sathianathenâ€ĸ~20 min readâ€ĸFeb 19, 2026

🤖 The Most Important Thing

If you get stuck on ANY step, take a screenshot of your error and paste it into Claude (claude.ai) or ChatGPT. Tell it what you're trying to do and what went wrong. It will walk you through the fix.

Don't give up — every error has a solution. Keep moving forward.

The 12-Step Setup

1

đŸ–Ĩī¸Create a Hetzner Account & Pick Your Server

Hetzner gives you a powerful server for â‚Ŧ4.35/month — the cheapest option out there.

Go to hetzner.com and create an account. Once you're in, go to the Cloud Console and click "Add Server".

Choose your settings:

  • Location: Pick the one closest to you. Falkenstein or Nuremberg for Europe. Ashburn for the US.
  • OS: Ubuntu 24.04
  • Type: CX22 — 2 vCPU, 4GB RAM, 40GB SSD — â‚Ŧ4.35/month
✅
CX22 is more than enough. You don't need anything bigger unless you're running multiple bots. OpenClaw is lightweight — most of the heavy work happens on Anthropic's servers, not yours.

Set up an SSH key (recommended)

An SSH key is like a digital password that's impossible to guess. It's a pair of files on your computer — one public (you give to Hetzner) and one private (stays on your computer). When you connect, they match up automatically.

Generate an SSH key (run this on YOUR computer, not the server)
ssh-keygen -t ed25519 -C "your-email@example.com"

Press Enter 3 times to accept the defaults. This creates your key pair.

Copy your public key to clipboard
# Mac
cat ~/.ssh/id_ed25519.pub | pbcopy

# Windows (PowerShell)
Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard

# Linux
cat ~/.ssh/id_ed25519.pub

Paste this into the "SSH Key" field in Hetzner when creating your server.

💡
Don't want to deal with SSH keys? You can also choose a password instead. Hetzner will email it to you. SSH keys are more secure, but a strong password works fine to get started.

Name your server something memorable (like "openclaw" or "my-ai-bot"), then click Create & Buy.

Wait about 30 seconds for the server to spin up. Once it's ready, copy the IP address — you'll need it in the next step.

2

🔌Connect to Your Server

You need to get into your server before you can set anything up.

You're going to use your computer's terminal to connect to the server over the internet. Don't worry — it's just typing a command.

Open your terminal

  • Mac: Press Cmd + Space, type "Terminal", press Enter
  • Windows: Search for "PowerShell" in the Start menu, open it
  • Linux: You already know 😉
Connect to your server
ssh root@YOUR_IP_ADDRESS

Replace YOUR_IP_ADDRESS with the IP you copied from Hetzner (something like 49.13.xx.xx).

The first time you connect, it'll ask: "Are you sure you want to continue connecting?" Type yes and press Enter. This is normal — it's just your computer confirming the server is legit.

✅
You're in! If you see something like root@openclaw:~# — congratulations, you're now controlling your server. Everything you type runs on the server, not your local computer.
3

👤Create a Dedicated User (Don't Run as Root)

Root can do anything — if something goes wrong, it can break everything. A regular user is safer.

Right now you're logged in as root — the all-powerful admin account. That's like driving with no speed limit. Let's create a regular user for OpenClaw instead.

Create a dedicated user
# Create a new user called "openclaw"
adduser openclaw

# Give it permission to use sudo when needed
usermod -aG sudo openclaw

# Switch to that user
su - openclaw

It'll ask you for a password and some optional info (full name, etc). Set a password, press Enter through the rest.

â„šī¸
From now on, you're the "openclaw" user. You should see openclaw@openclaw:~$ in your terminal. All the following commands should be run as this user.
đŸ’Ŧ

Need help with any of these steps? Join 50+ AI operators who help each other set up and optimize their OpenClaw instances.

Join the AI Operators community →
4

đŸ“ĻInstall Node.js

OpenClaw is built on Node.js. You need version 22 or higher.

Node.js is the engine that runs OpenClaw. Think of it like needing Java to run Minecraft — OpenClaw needs Node.js to work.

Install Node.js 22
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs

The first command adds the Node.js download source. The second installs it. This might take a minute.

Verify it installed correctly
node --version

You should see something like v22.x.x. If you see that, you're good. If not, run the install commands again.

5

đŸĻžInstall OpenClaw

This is the main event — getting OpenClaw on your server.

Install OpenClaw
curl -fsSL https://openclaw.ai/install.sh | bash

This downloads and installs OpenClaw. Wait for it to finish.

Run the onboarding wizard

Start the setup wizard
openclaw onboard --install-daemon

The wizard will walk you through the initial setup. It'll ask you for:

  • API Key: Your Anthropic API key (we'll set this up in Step 7 — you can skip for now and add it later)
  • Channel setup: Which messaging platform to connect (Telegram, WhatsApp, etc.)
  • Daemon install: The --install-daemon flag makes OpenClaw start automatically when your server boots

Verify it's running

Check gateway status
openclaw gateway status

You should see something telling you the gateway is running. If it says "running" — you're golden.

✅
OpenClaw is installed! The hard part is done. Now we just need to connect it to Telegram and configure a few things.
6

📱Connect Telegram

Telegram is the easiest way to talk to your AI assistant from your phone.

You're going to create a Telegram bot and connect it to OpenClaw. This lets you message your AI assistant just like texting a friend.

Step A: Create your bot

  1. Open Telegram on your phone
  2. Search for @BotFather and open a chat with it
  3. Send /newbot
  4. Pick a name for your bot (like "My AI Assistant")
  5. Pick a username (must end in "bot", like "myai_helper_bot")
  6. BotFather will give you a bot token — it looks like 123456789:ABCdef...
  7. Copy that token. You need it next.

Step B: Add the token to your config

Open your OpenClaw config file:

Edit your config
nano ~/.openclaw/openclaw.json

Add the Telegram section (or update it if it already exists):

Telegram config in openclaw.json
{
  "channels": {
    "telegram": {
      "botToken": "YOUR_BOT_TOKEN_FROM_BOTFATHER",
      "dmPolicy": "pairing",
      "groupPolicy": "disabled"
    }
  }
}

Save the file: Ctrl+X → Y → Enter.

Step C: Restart and pair

Restart the gateway
openclaw gateway restart

Now open Telegram and send a message to your bot. Because we set dmPolicy to "pairing", the first time you message it, the bot will give you a pairing code. Run the command it tells you to approve the pairing. After that, you're connected!

💡
What's "pairing"? It's a security feature. The first time someone messages your bot, they get a one-time code. You have to approve it on the server before they can use the bot. This prevents random people from using your AI.
🚀

Halfway there! Join the AI Operators community to share your setup and get tips from experienced builders.

Join the AI Operators community →
7

🔑Set Up Your API Key

The API key lets OpenClaw talk to Claude (the AI brain behind everything).

OpenClaw needs an API key from Anthropic to access Claude. This is what you're paying for when you use the AI — each message costs a tiny amount.

Get your API key

  1. Go to console.anthropic.com
  2. Create an account or sign in
  3. Go to API Keys
  4. Click Create Key
  5. Copy the key — you won't see it again!

Understanding the models

  • Claude Opus — The smartest model. Best for complex reasoning and creative work. Most expensive per message.
  • Claude Sonnet — Fast and capable. Great balance of quality and cost. Start here.
  • Claude Haiku — The fastest model. Cheapest per message. Good for simple tasks.
â„šī¸
Budget tip: Start with Sonnet for everyday use. It's fast, smart, and won't burn through your credits. You can always upgrade to Opus for specific tasks later.

Add your API key via the onboarding wizard or directly in your config file. If you already ran the wizard and it asked for the key, you're all set.

💡
Want unlimited usage? Anthropic offers a Claude Max subscription at $100/month for unlimited API calls. If you're going to use your bot heavily, this is the most cost-effective option.
8

🔒Basic Security Setup

Your server is on the internet. Let's make sure only YOU can access it.

We're going to do three quick things: change the default port, set a password, and turn on the firewall.

Change the default port

OpenClaw runs on port 8080 by default. That's public knowledge. Let's change it so automated scanners don't find your bot.

Add to your openclaw.json
{
  "gateway": {
    "port": 39217
  }
}

Pick any number between 10000 and 65535. Don't use the example — pick your own.

Set an auth token

This is like a password for the OpenClaw gateway itself. Anyone trying to connect needs this token.

Add auth to your openclaw.json
{
  "gateway": {
    "port": 39217,
    "auth": {
      "mode": "token",
      "token": "YOUR-STRONG-PASSWORD-HERE"
    }
  }
}

Use a long random password — 20+ characters. Mix letters, numbers, and symbols.

Turn on the firewall

Set up UFW firewall
# Allow your OpenClaw port
sudo ufw allow 39217/tcp

# Allow SSH (so you don't lock yourself out!)
sudo ufw allow ssh

# Turn it on
sudo ufw enable

# Verify it's working
sudo ufw status

UFW blocks all incoming connections except the ones you specifically allowed. Everything else gets silently dropped.

âš ī¸
Replace 39217 with YOUR chosen port number in the UFW command above. If you used a different port, use that number instead.

Want to go deeper on security? Check out the full guide: OpenClaw Security 101 — 13 steps to lock down your AI assistant like a pro.

9

đŸŗInstall Docker (For Sandbox)

Docker lets OpenClaw run subagents in sealed containers so they can't mess up your server.

OpenClaw can spawn "subagents" — smaller AI workers that handle tasks autonomously. Docker puts them in sealed containers so even if something goes wrong, your server stays safe.

Install Docker
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker openclaw

The first command installs Docker. The second gives your openclaw user permission to use it.

âš ī¸
You must log out and back in for the Docker permissions to take effect:
Log out and back in
exit
su - openclaw

Add sandbox config

Add this to your openclaw.json:

Sandbox config in openclaw.json
{
  "agents": {
    "defaults": {
      "sandbox": {
        "mode": "non-main",
        "workspaceAccess": "rw",
        "network": "bridge"
      }
    }
  }
}
  • "mode": "non-main" — Subagents run in Docker containers. The main agent runs normally.
  • "workspaceAccess": "rw" — Subagents can read and write files in the workspace.
  • "network": "bridge" — Subagents can access the internet (needed for things like npm install or git push).
10

📋Your Complete Config

Here's everything combined into one copy-pasteable config file.

Open your config file and replace everything with this complete configuration:

Edit the config file
nano ~/.openclaw/openclaw.json
~/.openclaw/openclaw.json — complete config
{
  "gateway": {
    "port": 39217,
    "auth": {
      "mode": "token",
      "token": "YOUR-STRONG-PASSWORD-HERE"
    }
  },
  "channels": {
    "telegram": {
      "botToken": "YOUR_BOT_TOKEN_FROM_BOTFATHER",
      "dmPolicy": "pairing",
      "groupPolicy": "disabled"
    }
  },
  "agents": {
    "defaults": {
      "sandbox": {
        "mode": "non-main",
        "workspaceAccess": "rw",
        "network": "bridge"
      }
    }
  }
}
âš ī¸
Replace these placeholders before saving:
  • 39217 → your chosen port number
  • YOUR-STRONG-PASSWORD-HERE → a long, random password
  • YOUR_BOT_TOKEN_FROM_BOTFATHER → your Telegram bot token

Save the file (Ctrl+X → Y → Enter), then restart:

Restart with new config
openclaw gateway restart
đŸŽ¯

Almost done! Connect with 50+ AI operators who are already running their own AI assistants.

Join the AI Operators community →
11

✅Test Everything

Let's make sure it all works before you celebrate.

Check the gateway

Verify gateway is running
openclaw gateway status

Should say it's running. If not, check the logs for errors.

Send a test message

Open Telegram. Send your bot a message like "Hello! What can you do?"

If it responds — you did it! 🎉 Your personal AI assistant is live.

Test subagents

Try asking your bot something that requires a subagent, like: "Spawn a subagent to research the latest news about AI." If it spawns a subagent and reports back, Docker sandbox is working.

✅
Congratulations! You now have a personal AI assistant running 24/7 on your own server. It's yours, it's private, and it's always on. You can message it from anywhere in the world.
12

💡Useful Tips & Tricks

A few things that'll make your life easier going forward.

Check logs

View OpenClaw logs
openclaw logs

If something isn't working, the logs will tell you why. Error messages here are your best debugging tool.

Restart OpenClaw

Restart the gateway
openclaw gateway restart

After any config change, restart the gateway for changes to take effect.

Update OpenClaw

Update to the latest version
npm install -g openclaw

Check for updates regularly. New versions include bug fixes and features.

Session cleanup (recommended)

OpenClaw stores conversation sessions. Over time they build up. Set up automatic cleanup every 72 hours by telling your bot:

Send this to your bot
Set up a cron job to clean up old sessions every 72 hours.

Back up your workspace with Git

Set up Git backup
cd ~/.openclaw/workspace
git init
git add -A
git commit -m "Initial backup"

# Add a remote (GitHub, etc) and push
# git remote add origin YOUR_REPO_URL
# git push -u origin main

This way if anything goes wrong, you can always restore your workspace files.

Frequently Asked Questions

How much does this cost per month?

Hetzner CX22 is â‚Ŧ4.35/month (~$5). Then you pay for API usage — typically $20–100/month depending on how much you use it. If you want unlimited Claude usage, the Claude Max subscription is $100/month.

Can I use a different cloud provider?

Absolutely. Any VPS works — DigitalOcean, Vultr, AWS, Linode, etc. Hetzner is just the cheapest option with great performance. The steps are almost identical on any Ubuntu server.

Do I need to be technical?

No. Follow each step exactly as written. If you get stuck, screenshot the error and paste it into Claude (claude.ai) or ChatGPT. They'll walk you through the fix.

What if I get an error?

Screenshot it. Paste it into Claude or ChatGPT. Tell it: "I'm following Johann's Hetzner setup guide and got this error on step X." It will fix it for you.

Can I run this on my laptop instead?

Yes, but a VPS runs 24/7. Your laptop doesn't. If you close your laptop, your bot goes offline. A $5/month server is always on.

How do I connect WhatsApp instead of Telegram?

Replace the Telegram config with a WhatsApp section, then run `openclaw channels login` to scan the QR code with your phone.

My bot isn't responding

Check three things: 1) Is the gateway running? (`openclaw gateway status`) 2) Is your bot token correct? 3) Have you completed the pairing process?

How do I stop my bot from spending too much on API?

Use Claude Sonnet for most tasks (it's much cheaper than Opus). Set up cost alerts on console.anthropic.com so you get notified before things get expensive.

Can I run multiple bots on one server?

Yes. Use different ports and separate config files for each instance. The CX22 can comfortably handle 2-3 bots.

Is my data safe?

Your data stays on YOUR server. OpenClaw doesn't send data anywhere except to the AI provider (Anthropic/OpenAI) for processing your messages. Nothing is stored on third-party servers.

Troubleshooting

Common errors and quick fixes:

"Permission Denied"

sudo chown -R $USER:$USER ~/.openclaw
# Or prefix your command with sudo

"Port already in use"

sudo lsof -i :8080
# Kill the process or change your port in openclaw.json

"npm: command not found"

# Node.js not installed — go back to Step 4
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs

"ECONNREFUSED"

# Gateway not running — start it
openclaw gateway start

"Authentication failed" (API key)

# Check your API key at console.anthropic.com
# Make sure it's correctly set in openclaw.json

"Docker: permission denied"

sudo usermod -aG docker $USER
# Then log out and back in:
exit
su - openclaw

What's Next?

AI Operators Community

Join 50+ AI operators sharing OpenClaw setups, automation workflows, and tips. Get help when you're stuck.

Join the AI Operators community →

Security Deep Dive

Now that your bot is running, lock it down properly. 13 steps to make your setup bulletproof.

Read the security guide →

Weekly Newsletter

Get the latest OpenClaw updates, new features, and automation ideas delivered to your inbox.

Subscribe →

Book a Call

Need hands-on help? Book a 1-on-1 setup call and I'll walk you through everything.

Book a call →

Last updated: February 19, 2026 â€ĸ By Johann Sathianathen