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.
đ¤ 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.
đ What You'll Set Up
The 12-Step Setup
đĨī¸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
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.
ssh-keygen -t ed25519 -C "your-email@example.com"Press Enter 3 times to accept the defaults. This creates your key pair.
# Mac
cat ~/.ssh/id_ed25519.pub | pbcopy
# Windows (PowerShell)
Get-Content ~/.ssh/id_ed25519.pub | Set-Clipboard
# Linux
cat ~/.ssh/id_ed25519.pubPaste this into the "SSH Key" field in Hetzner when creating your server.
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.
đ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 đ
ssh root@YOUR_IP_ADDRESSReplace 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.
root@openclaw:~# â congratulations, you're now controlling your server. Everything you type runs on the server, not your local computer.đ¤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 new user called "openclaw"
adduser openclaw
# Give it permission to use sudo when needed
usermod -aG sudo openclaw
# Switch to that user
su - openclawIt'll ask you for a password and some optional info (full name, etc). Set a password, press Enter through the rest.
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 âđĻ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.
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejsThe first command adds the Node.js download source. The second installs it. This might take a minute.
node --versionYou should see something like v22.x.x. If you see that, you're good. If not, run the install commands again.
đĻInstall OpenClaw
This is the main event â getting OpenClaw on your server.
curl -fsSL https://openclaw.ai/install.sh | bashThis downloads and installs OpenClaw. Wait for it to finish.
Run the onboarding wizard
openclaw onboard --install-daemonThe 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-daemonflag makes OpenClaw start automatically when your server boots
Verify it's running
openclaw gateway statusYou should see something telling you the gateway is running. If it says "running" â you're golden.
đą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
- Open Telegram on your phone
- Search for @BotFather and open a chat with it
- Send
/newbot - Pick a name for your bot (like "My AI Assistant")
- Pick a username (must end in "bot", like "myai_helper_bot")
- BotFather will give you a bot token â it looks like
123456789:ABCdef... - Copy that token. You need it next.
Step B: Add the token to your config
Open your OpenClaw config file:
nano ~/.openclaw/openclaw.jsonAdd the Telegram section (or update it if it already exists):
{
"channels": {
"telegram": {
"botToken": "YOUR_BOT_TOKEN_FROM_BOTFATHER",
"dmPolicy": "pairing",
"groupPolicy": "disabled"
}
}
}Save the file: Ctrl+X â Y â Enter.
Step C: Restart and pair
openclaw gateway restartNow 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!
Halfway there! Join the AI Operators community to share your setup and get tips from experienced builders.
Join the AI Operators community âđ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
- Go to console.anthropic.com
- Create an account or sign in
- Go to API Keys
- Click Create Key
- 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.
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.
đ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.
{
"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.
{
"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
# 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 statusUFW blocks all incoming connections except the ones you specifically allowed. Everything else gets silently dropped.
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.
đŗ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.
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker openclawThe first command installs Docker. The second gives your openclaw user permission to use it.
exit
su - openclawAdd sandbox config
Add this to your 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 likenpm installorgit push).
đYour Complete Config
Here's everything combined into one copy-pasteable config file.
Open your config file and replace everything with this complete configuration:
nano ~/.openclaw/openclaw.json{
"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"
}
}
}
}39217â your chosen port numberYOUR-STRONG-PASSWORD-HEREâ a long, random passwordYOUR_BOT_TOKEN_FROM_BOTFATHERâ your Telegram bot token
Save the file (Ctrl+X â Y â Enter), then restart:
openclaw gateway restartAlmost done! Connect with 50+ AI operators who are already running their own AI assistants.
Join the AI Operators community ââ Test Everything
Let's make sure it all works before you celebrate.
Check the gateway
openclaw gateway statusShould 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.
đĄUseful Tips & Tricks
A few things that'll make your life easier going forward.
Check logs
openclaw logsIf something isn't working, the logs will tell you why. Error messages here are your best debugging tool.
Restart OpenClaw
openclaw gateway restartAfter any config change, restart the gateway for changes to take effect.
Update OpenClaw
npm install -g openclawCheck 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:
Set up a cron job to clean up old sessions every 72 hours.Back up your workspace with Git
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 mainThis 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 - openclawWhat'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