Table of Contents
- What is OpenClaw?
- Prerequisites
- Option A: Google Cloud Free Tier (FREE)
- Option B: Hostinger VPS (Paid - $5/month)
- Post-Installation: Configure OpenClaw
- Making OpenClaw Run Forever with PM2
- Telegram Setup & Pairing
- WhatsApp Setup (Optional)
- Troubleshooting
- Quick Reference Commands
What is OpenClaw?
OpenClaw (formerly Moltbot/Clawdbot) is an AI-powered automation agent that connects to messaging platforms like Telegram, WhatsApp, Slack, and more. Once set up on a cloud server, it runs 24/7, responding to your messages and executing tasks even when you're asleep.
Why run it on a server instead of your Mac/PC?
- Runs 24/7 without keeping your computer on
- No battery drain or fan noise
- Accessible from anywhere
- More reliable than local setups
Prerequisites
Before starting, you'll need:
- A Telegram Bot Token — Get one from @BotFather on Telegram
- An AI API Key — Either:
- Anthropic API key from console.anthropic.com
- OpenRouter API key from openrouter.ai
- A cloud server — Google Cloud (free) or Hostinger VPS ($5/month)
Option A: Google Cloud Free Tier (FREE)
Google Cloud offers an always-free e2-micro instance that's perfect for running OpenClaw.
Step 1: Create Google Cloud Account
- Go to cloud.google.com
- Click "Get started for free"
- Sign in with your Google account
- Enter billing information (you get $300 free credits + always-free tier)
- Complete the setup wizard
Step 2: Create a Virtual Machine
- In the Google Cloud Console, click the hamburger menu (☰) in the top-left
- Navigate to Compute Engine → VM instances
- Click "Create Instance"
- Configure your VM: Name:
openclaw-serverRegion: Choose one of these FREE regions:Machine type:e2-micro(this is the FREE tier!) Boot disk: Click "Change"us-west1(Oregon)us-central1(Iowa)us-east1(South Carolina)
- Operating system:
Ubuntu - Version:
Ubuntu 22.04 LTSorUbuntu 24.04 LTS - Size:
30 GB(free tier allows up to 30GB) - Under Firewall, check:
- ✅ Allow HTTP traffic
- ✅ Allow HTTPS traffic
- Click "Create"
Wait 1-2 minutes for your VM to spin up.
Step 3: Connect to Your Server
- Find your new VM in the list
- Click the "SSH" button (opens a browser terminal)
- You're now connected to your server!
Continue to Post-Installation: Configure OpenClaw
Option B: Hostinger VPS (Paid)
Hostinger offers affordable VPS hosting with better performance than free tiers.
Step 1: Purchase a VPS
- Go to hostinger.com/vps-hosting
- Choose KVM 1 plan (cheapest, sufficient for OpenClaw)
- Select Ubuntu 24.04 as your operating system
- Complete checkout
You'll receive an email with your server IP and root password.
Step 2: Connect to Your Server
On Mac/Linux:
ssh root@YOUR_SERVER_IPOn Windows: Use PuTTY or Windows Terminal.
Continue to Post-Installation: Configure OpenClaw
Post-Installation: Configure OpenClaw
Once connected to your server via SSH, follow these steps:
Step 1: Update System & Install Dependencies
# Update system packages
sudo apt update && sudo apt upgrade -y
# Install git (required for npm packages)
sudo apt install -y git
# Install Node.js 22.x
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs
# Verify installation
node --version
npm --versionStep 2: Create a Dedicated User for OpenClaw
# Create user (as root)
sudo adduser openclaw --disabled-password --gecos ""
# Switch to the new user
sudo su - openclawStep 3: Install OpenClaw
# Set up npm global directory
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# Install OpenClaw globally
npm install -g openclaw
# Verify installation
openclaw --versionStep 4: Initialize OpenClaw
openclaw setupStep 5: Configure OpenClaw
Run the configuration wizard:
openclaw configureImportant settings to configure:
- Gateway Location: Select "Local (this machine)"
- Sections to configure: Select these:
- ✅ Gateway
- ✅ Model
- ✅ Channels
- Gateway settings:
- Port:
18789(default) - Bind mode:
Loopback (Local only) - Auth:
Token (Recommended) - Tailscale:
Off
- Port:
- Model settings:
- Provider:
Anthropic(recommended) orOpenRouter - Enter your API key when prompted
- Important: Make sure to select an actual model like
anthropic/claude-sonnet-4-20250514as default (NOTopenrouter/auto)
- Provider:
- Channels:
- Select
Telegram (Bot API) - Enter your Telegram Bot Token from @BotFather
- DM Policy:
pairing(recommended for security)
- Select
- Continue to finish configuration
Making OpenClaw Run Forever with PM2
PM2 keeps OpenClaw running 24/7, even after you close SSH.
Step 1: Install PM2
# Exit to root user first
exit
# Install PM2 globally
sudo npm install -g pm2
# Switch back to openclaw user
sudo su - openclawStep 2: Start OpenClaw with PM2
Important: The command is openclaw gateway, NOT openclaw start!
pm2 start "openclaw gateway" --name openclaw
pm2 saveStep 3: Configure Auto-Start on Reboot
pm2 startupPM2 will output a command. Copy that command and run it as root:
# Exit to root
exit
# Run the command PM2 gave you (example):
sudo env PATH=$PATH:/usr/bin /home/openclaw/.npm-global/lib/node_modules/pm2/bin/pm2 startup systemd -u openclaw --hp /home/openclaw
# Switch back to openclaw
sudo su - openclaw
# Save the process list
pm2 saveStep 4: Verify OpenClaw is Running
pm2 status
pm2 logs openclaw --lines 20You should see:
- Status:
online - Logs showing:
[gateway] listening on ws://127.0.0.1:18789 - Logs showing:
[telegram] starting provider
Telegram Setup & Pairing
Step 1: Message Your Bot
Open Telegram and send any message to your bot (the one you created with @BotFather).
Step 2: Approve Your Account
You'll receive a message like:
OpenClaw: access not configured.
Your Telegram user id: 1234567890
Pairing code: ABC123XY
Ask the bot owner to approve with:
openclaw pairing approve telegram <code>Step 3: Run the Approval Command
In your SSH terminal:
bash
openclaw pairing approve telegram ABC123XYReplace ABC123XY with your actual pairing code.
Step 4: Test the Bot
Send another message to your Telegram bot. It should now respond!
WhatsApp Setup (Optional)
WhatsApp integration works differently from Telegram. Instead of creating a separate bot, OpenClaw connects to YOUR personal WhatsApp account via WhatsApp Web.
Important: After setup, when someone messages your WhatsApp number, OpenClaw can see and respond to those messages.
Prerequisites for WhatsApp
- WhatsApp installed on your phone
- Your phone connected to the internet
- Available linked device slot (WhatsApp allows limited linked devices)
Step 1: Configure WhatsApp Channel
openclaw configure- Select Channels when prompted
- Choose WhatsApp from the channel list
- Set DM Policy to pairing (recommended for security)
- Continue to finish
Step 2: Link Your WhatsApp Account
Run this command to display the QR code:
openclaw channels login whatsapp --verboseYou'll see a QR code displayed in your terminal.
Step 3: Scan the QR Code
- Open WhatsApp on your phone
- Go to Settings → Linked Devices
- Tap Link a Device
- Scan the QR code shown in your terminal
Step 4: Restart OpenClaw
pm2 restart openclawStep 5: Verify WhatsApp is Connected
pm2 logs openclaw --lines 20Look for: [whatsapp] starting provider in the logs.
You can also check status with:
openclaw statusStep 6: Test WhatsApp
Option A: Ask a friend to message your WhatsApp number
Option B: Message yourself:
- Save your own phone number as a contact
- Open WhatsApp and start a chat with yourself
- Send a message — OpenClaw should respond
WhatsApp Access Control
Since OpenClaw uses your personal WhatsApp, you'll want to control who it responds to.
Set up pairing (recommended):
When someone new messages you, they'll receive a pairing code. Approve them with:
openclaw pairing approve whatsapp <CODE>Check pending requests:
openclaw pairing list whatsappWhatsApp Troubleshooting
QR code not showing:
openclaw channels login whatsapp --verboseWhatsApp disconnected: Your phone may have gone offline. Re-scan the QR code:
openclaw channels login whatsapp --verboseCheck WhatsApp status:
openclaw statusPhone requirement: Unlike Telegram bots, WhatsApp Web requires your phone to stay connected to the internet. If your phone loses connection for too long, you may need to re-link.
Troubleshooting
Error: "unknown command 'start'"
Cause: Using wrong command Solution: Use openclaw gateway instead of openclaw start
pm2 delete openclaw
pm2 start "openclaw gateway" --name openclaw
pm2 saveError: "Gateway start blocked: set gateway.mode=local"
Cause: Gateway mode not configured Solution: Set it manually:
pm2 stop openclaw
openclaw config set gateway.mode local
pm2 restart openclawOr run openclaw configure and select "Gateway" section.
Error: "Unknown model: openrouter/auto"
Cause: Invalid default model selected Solution: Set a valid model:
pm2 stop openclaw
# Edit the config file
cat ~/.openclaw/openclaw.json | grep -A5 "model"
# Use sed to replace the model (example for Anthropic):
sed -i 's/"primary": "openrouter\/auto"/"primary": "anthropic\/claude-sonnet-4-20250514"/' ~/.openclaw/openclaw.json
pm2 restart openclawOr run openclaw configure → Model → select Anthropic and a specific model.
Error: "No API key found for provider"
Cause: API key not configured Solution: Run configure and add your API key:
openclaw configureSelect "Model" and enter your Anthropic or OpenRouter API key.
Error: "All models failed... rate_limit"
Cause: API key is rate limited or invalid Solution:
- Check your API key is valid at console.anthropic.com
- Regenerate the key if needed
- Update in OpenClaw:
openclaw configure
# Select Model → Anthropic → Enter new API key
pm2 restart openclawError: "No pending pairing request found"
Cause: Pairing code expired Solution:
- Message your Telegram bot again to get a new code
- Run the approve command with the new code within 5 minutes
Error: "npm error syscall spawn git"
Cause: Git not installed Solution:
sudo apt install -y gitError: "EACCES permission denied"
Cause: Running npm without sudo for global packages Solution:
sudo npm install -g <package>OpenClaw stops when I close SSH
Cause: PM2 not set up correctly Solution: Follow the PM2 setup section completely, including pm2 startup and pm2 save.
How to check if OpenClaw is running
pm2 status
pm2 logs openclaw --lines 20How to restart OpenClaw
pm2 restart openclawHow to view all logs
pm2 logs openclaw --lines 100
# or
cat /tmp/openclaw/openclaw-$(date +%Y-%m-%d).logQuick Reference Commands
Server Connection
# Google Cloud
gcloud compute ssh openclaw-server
# Hostinger/Direct SSH
ssh root@YOUR_SERVER_IP
sudo su - openclawPM2 Commands
pm2 status # Check if running
pm2 logs openclaw # View live logs
pm2 restart openclaw # Restart
pm2 stop openclaw # Stop
pm2 delete openclaw # Remove from PM2
pm2 save # Save process listOpenClaw Commands
openclaw --version # Check version
openclaw configure # Run configuration wizard
openclaw models # View model configuration
openclaw status # Check channel health
openclaw logs --follow # View gateway logs
openclaw pairing approve telegram <CODE> # Approve Telegram user
openclaw pairing approve whatsapp <CODE> # Approve WhatsApp user
openclaw pairing list telegram # List pending Telegram requests
openclaw pairing list whatsapp # List pending WhatsApp requests
openclaw channels login whatsapp --verbose # Link WhatsApp (show QR code)User Switching
sudo su - openclaw # Switch to openclaw user
exit # Switch back to previous user
whoami # Check current userWhat's Next?
Now that OpenClaw is running 24/7:
- Connect more platforms — WhatsApp, Slack, Discord, etc.
- Customize your bot — Set up skills and automations
- Explore the dashboard — Run
openclaw dashboardto access the web UI
For more information, visit the official documentation at docs.openclaw.ai
Created by The AI Driven Marketer