Back to Blog

Setting Up OpenClaw on a $5/Month VPS: Complete Guide

## Why Self-Host OpenClaw on a VPS? Running OpenClaw on your own VPS gives you full control over your AI assistant. Why rely on cloud services that can disappear or change prices overnight? With a self-hosted setup, you have no cloud vendor lock-in, no hidden fees, and full ownership of your data. Plus, for just $5/month, you turn a budget VPS into a 24/7 AI powerhouse, always available to work on your commands. This approach also ensures privacy and security. By keeping your data on your server, you eliminate concerns about how third parties store, process, or analyze it. ## Prerequisites To kick off your OpenClaw setup, you’ll need the following: - **VPS Provider:** A VPS plan from a provider like DigitalOcean, Hetzner, Vultr, or Linode. All of these providers offer plans starting at $5/month. - **Operating System:** Ubuntu 22.04 or newer. - **Access Credentials:** You’ll need SSH access to the server. - **Skill Level:** Basic familiarity with the terminal. You don’t need to be a Linux guru, but knowing how to edit files, run commands, and troubleshoot is helpful. For stronger performance, opt for the recommended specs: - **RAM:** 2GB (though 1GB will work if you add swap memory). - **Storage:** At least 25GB of SSD storage. - **CPU:** Ensure the VPS has at least 1 virtual CPU. ## Step 1: Provision Your VPS First, sign up for any VPS provider that suits your requirements. If latency is important, select a datacenter region close to your geographical location. For this tutorial, you’ll create a server with the following specs: - **OS:** Ubuntu 22.04 LTS - **RAM:** 1GB minimum - **Storage:** 25GB SSD - **Region:** Choose the closest datacenter to minimize delays. Once your VPS is up, note its IP address. You’ll use it for SSH access in the next step. ## Step 2: Initial Server Setup When you get access to your brand-new VPS, a few critical steps are needed to prepare it for action. Run the following commands: ```bash # SSH into your server (replace with your VPS IP) ssh root@your-server-ip # Keep your server software up to date apt update && apt upgrade -y ### Create a Dedicated User Using your server as `root` poses a security risk. Instead, create a dedicated user. ```bash # Add a new user adduser openclaw # Grant admin (sudo) privileges to the user usermod -aG sudo openclaw Log out from the root account and re-login as your new user: ```bash ssh openclaw@your-server-ip ``` ### Set Up Your Firewall Protect your server by specifying which ports can be accessed externally. OpenClaw uses port `3000` (by default). ```bash # Allow traffic for SSH sudo ufw allow OpenSSH # Allow OpenClaw's default port sudo ufw allow 3000 # Enable and check firewall status sudo ufw enable sudo ufw status ``` ## Step 3: Install Node.js OpenClaw relies on Node.js to run. Using the latest long-term support (LTS) version ensures stability. ```bash # Install Node.js 20.x curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt install -y nodejs # Verify that it installed correctly node --version # Should return something like 'v20.x.x' npm --version # Verifies npm (Node Package Manager) ``` If you encounter issues installing Node.js, check your server’s connectivity or retry with `nvm`, the Node Version Manager, which offers better version control. ## Step 4: Install OpenClaw Now that your server is set up, it’s time for OpenClaw. ```bash # Install the OpenClaw CLI globally npm install -g openclaw # Create a workspace directory mkdir ~/.openclaw && cd ~/.openclaw # Initialize OpenClaw workspace openclaw init ``` ### Set Up Your AI Provider Configure OpenClaw with your preferred AI backend (e.g., Anthropic, OpenAI). In this example, we’ll use Anthropic (Claude). ```bash openclaw config set provider anthropic openclaw config set apiKey <your-anthropic-api-key> ``` For OpenAI: ```bash openclaw config set provider openai openclaw config set apiKey <your-openai-api-key> ``` ## Step 5: Run as a Background Service To maintain uptime, configure OpenClaw to run as a system-wide service via `systemd`. This eliminates the need to manually restart it after reboots. ```bash # Create a systemd service file for OpenClaw sudo tee /etc/systemd/system/openclaw.service << 'EOF' [Unit] Description=OpenClaw AI Agent After=network.target [Service] Type=simple User=openclaw ExecStart=/usr/bin/openclaw gateway start Restart=always RestartSec=10 [Install] WantedBy=multi-user.target EOF ``` Activate the service: ```bash sudo systemctl enable openclaw sudo systemctl start openclaw sudo systemctl status openclaw ``` ## Step 6: Secure Your Installation Running OpenClaw safely means taking a few key steps: 1. **SSL Certificates:** Use Let’s Encrypt or another service to secure any web interfaces. Example tool: `certbot`. 2. **Authentication:** Enable `config.auth` to restrict access to trusted users. 3. **Updates:** Periodically run: ```bash npm update -g openclaw ``` ### Adding Swap Space For servers with just 1GB of RAM, adding swap space reduces the chance of crashes: ```bash sudo fallocate -l 1G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile # Make swap persistent echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab ``` ## Additional Tips for Maximizing OpenClaw - **Reduce Latency:** Place your VPS close to data centers hosting your chosen AI API. - **Monitor Resources:** Use tools like `htop` for live performance monitoring. ## New Section: Backups and Data Safety If you’re using OpenClaw for critical tasks, regular backups are crucial. Here’s a simple system to automate backups: ```bash # Backing up your OpenClaw config and data tar -czvf openclaw-backup-$(date +%F).tar.gz ~/.openclaw ``` Schedule this command as a cron job: ```bash crontab -e # Add: 0 2 * * * tar -czvf ~/openclaw-backup-$(date +\%F).tar.gz ~/.openclaw ``` ## New Section: Scaling Beyond a $5 VPS If your requirements outgrow a $5 VPS (e.g., heavier workflows), consider: - Moving to a $10/month plan with higher CPU and RAM. - Using container orchestration like Docker to offload components. - Distributing tasks onto multiple servers. ## FAQ ### 1. **What happens if my VPS runs out of memory?** By default, OpenClaw may exit if memory runs critically low. To prevent this: - Add swap memory (above example). - Upgrade your VPS to at least 2GB of RAM. ### 2. **Can I use OpenClaw with a domain name?** Yes. Point your domain/subdomain to the VPS IP using DNS A records. Then secure it with SSL via Let’s Encrypt. ### 3. **What if the OpenClaw service fails to start?** Check logs using: ```bash journalctl -u openclaw -f ``` Common issues include incorrect permissions, missing dependencies, or incorrect API keys. ### 4. **Is this guide beginner-friendly?** It assumes basic Linux terminal knowledge. For newcomers, practice tasks like editing files (`nano`, `vi`) and exploring `Ubuntu Server`. ### 5. **Can I install custom OpenClaw skills on this setup?** Absolutely. Once OpenClaw is running, explore the [ClawHub marketplace](https://clawhub.com) or use the Skill Creator. ## Conclusion For just $5/month, you’ve turned a budget VPS into an always-available AI assistant. By following this guide, you now have a robust Node.js environment running OpenClaw securely. From firewall and backup techniques to scaling considerations, your OpenClaw is ready for real-world workloads. Take it further by exploring advanced configurations, securing SSL, and expanding your skill library. ## New Section: Comparing VPS Providers for OpenClaw Hosting Choosing the right VPS provider can significantly impact your OpenClaw experience. Here’s a comparison of popular $5/month VPS providers to help you decide: ### 1. **DigitalOcean** - **Pros:** User-friendly interface, detailed tutorials, reliable uptime. - **Cons:** Slightly higher latency in some regions compared to competitors. - **Best For:** Beginners who value a smooth setup process. ### 2. **Hetzner** - **Pros:** Affordable pricing, high-performance servers, European datacenters. - **Cons:** Limited datacenters outside Europe, harder-to-navigate dashboard. - **Best For:** Customers close to Europe who need high performance on a budget. ### 3. **Vultr** - **Pros:** Global datacenter locations, custom ISO support, good throughput. - **Cons:** Lower-tier plans lack DDoS protection; customer support is basic. - **Best For:** Users requiring diverse regional options and flexibility in server configuration. ### 4. **Linode** - **Pros:** Reliable hardware, straightforward pricing, solid customer support. - **Cons:** Slightly older hardware compared to newer competitors. - **Best For:** Developers looking for simplicity and reliability over cutting-edge offerings. #### Factors to Consider: Before choosing, evaluate: - **Datacenter proximity:** Opt for a provider with locations near your users or workflows to reduce latency. - **Support options:** Some providers offer faster or more comprehensive customer service. - **Performance benchmarks:** Read user reviews or run your own stress tests on trial periods. --- ## New Section: Real-World Use Cases for OpenClaw on a VPS An OpenClaw setup on a $5 VPS isn’t just a budget experiment; it’s a practical platform for real-world applications. Here are some use cases to inspire you: ### 1. **Personal Productivity Assistant** - Automate repetitive tasks like scheduling meetings or drafting emails. - Integrate with your calendar and task manager via OpenClaw’s skill system. - Example: “Every morning, summarize today’s calendar events and email updates.” ### 2. **Customer Support Bot** - Provide 24/7 responses to frequently asked questions on your website. - A $5 VPS can handle hundreds of customer queries daily for small businesses. - Example: Deploy AI-powered bots to field pre-sales inquiries and prioritize leads. ### 3. **Content Creation Helper** - Use OpenClaw to generate first drafts for blog posts, social media captions, or reports. - Automate image generation or transcription tasks. - Example: Schedule a skill to turn meeting transcripts into polished minutes. ### 4. **Web Automation** - Test and monitor websites or APIs with custom OpenClaw scripts. - Crawl data for specific insights or metrics. - Example: A real estate crawler that collects rental listings matching specific parameters. --- ## New Section: Advanced Troubleshooting Techniques Even with a well-configured setup, issues can sometimes arise. Here are deeper troubleshooting methods to resolve problems: ### 1. **Diagnosing Service Failures** If `systemctl status openclaw` shows repeated restarts: - **Logs:** Check logs for error messages: ```bash journalctl -u openclaw -f ``` - **Reinstall:** Reinstall OpenClaw if dependencies are corrupted: ```bash sudo npm uninstall -g openclaw && sudo npm install -g openclaw ``` ### 2. **Debugging Network Issues** If OpenClaw fails to connect to providers: - **Firewall Check:** Ensure ports 3000 (default) and outbound HTTP/HTTPS are open: ```bash sudo ufw status ``` - **Ping Test:** Verify connectivity to your provider’s API endpoint: ```bash ping api.anthropic.com ``` ### 3. **Handling High CPU/RAM Usage** OpenClaw’s skills or requests may overload a small VPS: - **Monitor Usage:** Install and run `htop` to visualize active processes: ```bash sudo apt install htop && htop ``` - **Restart OpenClaw:** Free up memory by restarting: ```bash sudo systemctl restart openclaw ``` ### 4. **Fixing Misconfigured API Keys** If responses are consistently empty or errors show invalid credentials: - **Reconfigure Your Provider:** ```bash openclaw config set apiKey <new-api-key> ``` - **Email Notifications:** Check your inbox for updates on revoked or expired keys. ### 5. **Investigating Storage Issues** Over time, log files or dependencies may eat up disk space: - **Clean Log Files:** Remove outdated files: ```bash sudo rm -rf ~/.openclaw/logs/* ``` - **Expand Storage (Cloud-Specific):** Upgrade your storage quota via your VPS dashboard if limits are hit. With these tips, even less-experienced users can resolve issues efficiently.