How to Run OpenClaw on Raspberry Pi: Complete Setup Guide
I tried running OpenClaw on my Raspberry Pi 4. It took three attempts before I got it working. The main problem? Node.js version compatibility on ARM architecture.
Here’s what I learned and how to avoid my mistakes.
The Challenge
OpenClaw runs on Node.js. Simple enough. But on Raspberry Pi, I hit several walls:
- Node.js 18 had module compatibility issues
- npm permission errors blocked global installation
- Memory constraints on my 4GB model caused crashes
- “Illegal instruction” errors from wrong ARM binary
After three failed attempts and hours of troubleshooting, I finally got a stable setup running 24/7. This guide shows you the working path.
Hardware Requirements
I tested on two Raspberry Pi models:
| Model | RAM | Result |
|---|---|---|
| Pi 4 (8GB) | 8GB | Works great, runs 5 agents |
| Pi 4 (4GB) | 4GB | Works with memory optimization |
The 8GB model is worth the extra cost if you’re serious about this. With 4GB, I had to enable swap and limit concurrent operations.
Minimum setup:
- Raspberry Pi 4 (4GB minimum, 8GB recommended)
- 16GB+ microSD card (Class 10) or USB SSD
- Official 5V/3A power supply
- Raspberry Pi OS Lite (64-bit) or Ubuntu Server ARM64
Step 1: Install Node.js 22
My first mistake was using Node.js 18. It installed fine, but OpenClaw threw errors about missing modules.
Use Node.js 22 LTS. Here’s the working method:
# Update systemsudo apt update && sudo apt upgrade -y
# Install build dependenciessudo apt install -y build-essential curl python3
# Add Node.js 22 repository (auto-detects ARM architecture)curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
# Install Node.jssudo apt install -y nodejs
# Verify installationnode --version # Should show v22.x.xnpm --versionThe NodeSource repository auto-detects your ARM version. This saved me from the “Illegal instruction” error I got with manually downloaded binaries.
Fixing npm Permission Errors
My second attempt failed with npm permission errors. The fix:
# Create npm global directorymkdir ~/.npm-global
# Configure npm to use user directorynpm config set prefix '~/.npm-global'
# Add to PATHecho 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrcsource ~/.bashrcDon’t use sudo npm install. That was my mistake. It creates permission problems later.
Step 2: Create Dedicated User
Running OpenClaw as my regular user felt risky. If something went wrong, an attacker would have access to all my files.
I created a dedicated user:
# Create openclaw usersudo adduser --disabled-password --gecos "" openclaw
# Add to sudo group (for service management)sudo usermod -aG sudo openclaw
# Configure passwordless sudo for systemdecho "openclaw ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/openclawsudo chmod 440 /etc/sudoers.d/openclawThis isolates OpenClaw from your personal files. A compromised agent can only access what’s in the openclaw user’s home directory.
Step 3: Install OpenClaw
Switch to the openclaw user and install:
# Switch to openclaw usersudo su - openclaw
# Configure npm prefixnpm config set prefix ~/.npm-global
# Install OpenClaw globallynpm install -g openclaw@latest
# Add to PATHecho 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.bashrcsource ~/.bashrc
# Verify installationopenclaw --versionRun Initial Configuration
# Run onboarding wizardopenclaw onboardThis generates your gateway token, configures authentication, and creates the initial agent. Configuration files go to ~/.openclaw/openclaw.json.
Step 4: Set Up Systemd Service
For 24/7 operation, I needed OpenClaw to start automatically and restart on failure.
sudo tee /etc/systemd/system/openclaw-gateway.service > /dev/null << 'EOF'[Unit]Description=OpenClaw Gateway (Always-On AI Assistant)After=network-online.targetWants=network-online.target
[Service]User=openclawWorkingDirectory=/home/openclawEnvironment=PATH=/usr/bin:/bin:/home/openclaw/.npm-global/binExecStart=/home/openclaw/.npm-global/bin/openclaw gateway --bind loopback --port 18789 --verboseRestart=alwaysRestartSec=5
# Security hardeningNoNewPrivileges=falsePrivateTmp=true
[Install]WantedBy=multi-user.targetEOFEnable and start:
# Reload systemdsudo systemctl daemon-reload
# Enable service (start on boot)sudo systemctl enable openclaw-gateway.service
# Start servicesudo systemctl start openclaw-gateway.service
# Check statussudo systemctl status openclaw-gateway.serviceCheck logs:
sudo journalctl -u openclaw-gateway.service -fStep 5: Configure Model (Local or Cloud)
OpenClaw needs a model backend. I tested two approaches.
Option A: Local Model with Ollama
For privacy, I ran models locally:
# Install Ollamacurl -fsSL https://ollama.com/install.sh | sh
# Pull lightweight model (good for Pi 4)ollama pull ministral-3:3bRecommended models for Raspberry Pi:
| Model | Size | Notes |
|---|---|---|
| ministral-3:3b | 3B | Best balance, fast |
| llama3.2:3b | 3B | Larger context window |
| qwen2.5:3b | 3B | Good for tool use |
On my 4GB Pi, the 3B models run fine. Larger models caused memory issues.
Option B: Cloud Models
For better reasoning quality, I configured cloud APIs:
# Configure Anthropic Claudeopenclaw models configure anthropic --api-key YOUR_KEY
# Set default modelopenclaw models aliases set default claude-sonnet-4.5I use a hybrid approach: local models for routine tasks, cloud models for complex reasoning. This keeps API costs down.
Step 6: Memory Optimization (4GB Model)
On my 4GB Pi, I hit memory constraints. Here’s what helped:
Enable Swap
# Check current swapfree -h
# Increase swap if neededsudo dphys-swapfile swapoffsudo nano /etc/dphys-swapfile# Set CONF_SWAPSIZE=2048sudo dphys-swapfile setupsudo dphys-swapfile swaponMonitor Memory Usage
# Watch memoryhtop
# Or simpler viewwatch -n 5 free -hLimit Node.js Memory
# Add to systemd service or .bashrcexport NODE_OPTIONS="--max-old-space-size=3072" # 3GB limitStep 7: Remote Access Setup
With OpenClaw bound to localhost, I needed a way to access it remotely.
Option A: SSH Tunnel (Simple)
# On your local machinessh -N -L 18789:127.0.0.1:18789 openclaw@YOUR_PI_IP
# Access at http://localhost:18789Option B: Tailscale (Recommended)
# Install Tailscale on Raspberry Picurl -fsSL https://tailscale.com/install.sh | shsudo tailscale up
# Now accessible from any device on your tailnetTailscale is more convenient than SSH tunnels. No port forwarding, no exposed services.
Step 8: Security Hardening
An AI agent with file system access is a security risk. I applied these hardening measures:
Run Security Audit
# Basic auditopenclaw security audit
# Deep audit with network checksopenclaw security audit --deep
# Auto-fix common issuesopenclaw security audit --fixRestrict Tool Access
Edit ~/.openclaw/openclaw.json:
{ "gateway": { "bind": "loopback", "auth": { "mode": "token", "token": "YOUR_SECURE_TOKEN" } }, "tools": { "profile": "messaging", "deny": ["group:automation", "group:runtime", "group:fs"], "exec": { "security": "deny", "ask": "always" } }}This restricts dangerous operations. File system and command execution require explicit approval.
Step 9: Install Skills
Skills extend OpenClaw’s capabilities. From the Reddit success case, these work well on Pi:
# Core skillsopenclaw skills install clawhubopenclaw skills install notionopenclaw skills install gog
# For local speech recognitionopenclaw skills install whisper
# For code assistanceopenclaw skills install nano-bananaMonitoring and Maintenance
Health Check Script
#!/bin/bash
echo "=== OpenClaw System Monitor ==="echo ""
echo "Memory Usage:"free -hecho ""
echo "CPU Temperature:"vcgencmd measure_tempecho ""
echo "OpenClaw Service Status:"sudo systemctl status openclaw-gateway.service --no-pager | head -n 15echo ""
echo "Recent Logs:"sudo journalctl -u openclaw-gateway.service -n 10 --no-pagerBackup Configuration
# Backup OpenClaw setuptar -czf openclaw-backup-$(date +%Y%m%d).tar.gz ~/.openclawUpdate OpenClaw
# Stop servicesudo systemctl stop openclaw-gateway.service
# Updatenpm update -g openclaw@latest
# Restartsudo systemctl start openclaw-gateway.service
# Verifyopenclaw --versionTroubleshooting Common Issues
”Illegal instruction” Error
This means wrong Node.js binary for your ARM version. Use NodeSource repository which auto-detects architecture.
npm Permission Errors
Don’t use sudo npm install. Configure npm to use your home directory:
mkdir ~/.npm-globalnpm config set prefix '~/.npm-global'Out of Memory
On 4GB model, enable swap and use smaller models:
# Enable swapsudo dphys-swapfile swapoff# Edit /etc/dphys-swapfile, set CONF_SWAPSIZE=2048sudo dphys-swapfile setupsudo dphys-swapfile swapon
# Use smaller modelollama pull ministral-3:3bService Won’t Start
Check logs:
sudo journalctl -u openclaw-gateway.service -n 50
# Common issue: wrong path in ExecStartls -la /home/openclaw/.npm-global/bin/openclawPerformance Tips
Use SSD Instead of microSD
microSD cards are slow. I switched to a USB 3.0 SSD and saw significant improvement:
# Mount SSDsudo mkdir -p /mnt/ssd/openclawsudo chown openclaw:openclaw /mnt/ssd/openclaw
# Move OpenClaw dataexport OPENCLAW_STATE_DIR=/mnt/ssd/openclawCPU Governor
Set to performance mode for consistent speed:
echo "performance" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governorWhat I Learned
Running OpenClaw on Raspberry Pi is possible but requires patience. The key challenges:
- Node.js compatibility: Use version 22, not 18
- Memory: 8GB model is worth the extra cost
- Permissions: Never use
sudo npm - Security: Bind to localhost, use VPN for remote access
- Models: 3B parameter models work well on Pi 4
After three weeks of running this setup, I have 5 agents running continuously with local memory. No cloud infrastructure costs. Complete data privacy. The setup took effort, but the result is worth it.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
- 👨💻 OpenClaw Documentation
- 👨💻 OpenClaw GitHub
- 👨💻 Node.js ARM Downloads
- 👨💻 Raspberry Pi Documentation
- 👨💻 Reddit: Running OpenClaw on Raspberry Pi
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments