How to Run Claude Code on VPS: Complete OpenClaw Setup Guide (2026)
Step-by-step guide to running Claude Code on a VPS with OpenClaw (formerly Clawdbot). Connect Claude to WhatsApp, Telegram, Discord from anywhere.
How to Run Claude Code on VPS: Complete OpenClaw Setup Guide (2026)
Want to run Claude Code (Anthropic's coding agent) on a VPS and access it from WhatsApp, Telegram, or Discord? This guide shows you how using OpenClaw — the open-source gateway that bridges AI agents to messaging platforms.
What is OpenClaw?
OpenClaw (formerly known as Clawdbot) is an open-source project that:
- Runs AI coding agents (Claude, GPT, etc.) on any server
- Bridges them to WhatsApp, Telegram, Discord, iMessage, and more
- Provides a web dashboard for management
- Supports persistent sessions and workspaces
- Works 24/7 on a VPS
Think of it as your personal AI assistant that never sleeps — running in the cloud, accessible from your phone.
Prerequisites
Before we start, you'll need:
- VPS with at least 1GB RAM (Oracle Free Tier, Hetzner, or any Linux server)
- Node.js 22+ installed
- Anthropic API key (for Claude) — Get one at console.anthropic.com
- A messaging account to connect (WhatsApp, Telegram bot token, or Discord bot)
Step 1: Install OpenClaw on Your VPS
SSH into your VPS and run the quick installer:
# Quick install (recommended)
curl -fsSL https://openclaw.bot/install.sh | bash
# Or via npm
npm install -g openclaw@latest
Verify the installation:
openclaw --version
Step 2: Run the Onboarding Wizard
OpenClaw includes an interactive setup wizard that handles most configuration:
openclaw onboard --install-daemon
The wizard will ask you to configure:
- Gateway settings — Where to run the server
- Authentication — Your Anthropic API key
- Channels — WhatsApp QR, Telegram token, Discord token
- Daemon installation — Auto-start on boot
Setting Up Anthropic API Key
When prompted for authentication, choose API Key and enter your Anthropic key:
? Select auth method: API Key
? Enter Anthropic API key: sk-ant-api03-xxxxx...
This key is stored securely in ~/.openclaw/openclaw.json.
Step 3: Connect a Messaging Channel
Option A: WhatsApp (Most Popular)
openclaw channels login
This displays a QR code. Scan it with WhatsApp → Settings → Linked Devices.
Option B: Telegram Bot
- Create a bot via @BotFather
- Copy the bot token
- Add it during onboarding or manually in config:
{
"channels": {
"telegram": {
"token": "YOUR_BOT_TOKEN"
}
}
}
Option C: Discord Bot
- Create a bot at Discord Developer Portal
- Enable Message Content Intent
- Add the bot token to config:
{
"channels": {
"discord": {
"token": "YOUR_DISCORD_BOT_TOKEN"
}
}
}
Step 4: Start the Gateway
If you installed the daemon during onboarding, it's already running. Check status:
openclaw gateway status
To start manually:
openclaw gateway --port 18789 --verbose
Access the web dashboard at: http://YOUR_VPS_IP:18789/
Step 5: Secure Your Setup
Add Gateway Authentication
For production, always add a token:
openclaw gateway --bind lan --token YOUR_SECRET_TOKEN
Or in ~/.openclaw/openclaw.json:
{
"gateway": {
"auth": {
"token": "YOUR_SECRET_TOKEN"
}
}
}
Restrict Access (Optional)
Limit who can message your bot:
{
"channels": {
"whatsapp": {
"allowFrom": ["+1234567890", "+0987654321"]
}
}
}
Step 6: Test Your Setup
Send a message to your connected channel:
- WhatsApp: Send a message to yourself (linked device shows it)
- Telegram: DM your bot
- Discord: Message in a channel where your bot is present
You should get a response from Claude!
Verify from Command Line
openclaw message send --target +1234567890 --message "Hello from OpenClaw!"
Advanced Configuration
Custom Workspace
Your AI agent works in a persistent workspace. Default: ~/.openclaw/workspace/
Add custom files here that Claude can access:
mkdir -p ~/.openclaw/workspace
echo "# My Project Notes" > ~/.openclaw/workspace/NOTES.md
Model Selection
Change the default model:
{
"agents": {
"defaults": {
"provider": "anthropic",
"model": "claude-sonnet-4-5"
}
}
}
Available models:
claude-sonnet-4-5(balanced, recommended)claude-opus-4-6(most capable)claude-haiku-4-5(fast, cheaper)
Enable Thinking Mode
For complex tasks, enable extended thinking:
{
"agents": {
"defaults": {
"thinking": "low"
}
}
}
Options: off, low, medium, high
VPS Provider Recommendations
| Provider | Cost | Notes |
|---|---|---|
| Oracle Cloud | Free | Always Free tier, ARM instances |
| Hetzner | ~$4/mo | Great performance, EU servers |
| Railway | $5/mo | One-click deploy, easy setup |
| Fly.io | ~$5/mo | Global edge deployment |
| DigitalOcean | $6/mo | Reliable, good documentation |
For the free option, see the Oracle Cloud guide.
Troubleshooting
"No auth configured"
Run openclaw health — if it shows no auth, re-run the wizard:
openclaw onboard
WhatsApp disconnects
This usually means the session expired. Re-link:
openclaw channels logout whatsapp
openclaw channels login
Gateway won't start
Check if the port is already in use:
lsof -i :18789
Kill the existing process or use a different port.
Permission denied
Make sure you're running as a user with write access to ~/.openclaw/.
Real-World Use Cases
Once running, here's what you can do:
- Code assistance — Ask Claude to write, review, or debug code
- File management — Claude can read/write files in your workspace
- Web research — Enable Brave Search for real-time information
- Automation — Set up cron jobs for periodic tasks
- Multi-device access — Message from any device, anywhere
Example Conversation
You: Create a Python script that scrapes Hacker News top stories
Claude: I'll create that for you. Let me write the script...
[Claude writes hn_scraper.py to your workspace]
Claude: Done! I've created `hn_scraper.py` in your workspace.
It fetches the top 30 stories from Hacker News and saves them
to a JSON file. Run it with: python hn_scraper.py
Conclusion
Running Claude Code on a VPS with OpenClaw gives you:
- ✅ 24/7 availability
- ✅ Access from any messaging app
- ✅ Persistent workspace and sessions
- ✅ Full coding agent capabilities
- ✅ Privacy (your server, your data)
The setup takes about 15 minutes, and you get a personal AI assistant that's always available.
Ready to start? Visit docs.openclaw.ai for the full documentation.
Resources:
Last Updated: February 2026
Related Articles
AI API Pricing 2026: Cost Strategies for LLM Economics
Compare AI API pricing across providers, analyze cost optimization strategies, and explore LLM economics trends for 2026.
LLM API Economics 2026: Smart Cost Optimization Strategies
Compare AI API pricing across Claude, GPT, Gemini and learn cost optimization strategies. When to use each tier and market trends for 2026.
AI Safety 2026: Constitutional Alignment Breakthroughs
Explore 2026 advances in AI safety from Anthropic, OpenAI, and DeepMind. Constitutional AI, RLHF improvements, and alignment techniques shaping responsible AI.