The Ultimate Guide to Self-Hosting OpenClaw: Build Your Own Private AI Assistant on a VPS
Setting up your own AI assistant shouldn't be a privilege reserved for tech giants. With OpenClaw (formerly known as Moltbot or Clawdbot), you can host a powerful, private AI bot right on your own server. Whether you want to automate your chats or have a dedicated AI companion available 24/7, self-hosting is the gold standard for privacy and reliability.
In this guide, we will walk you through the entire process of installing OpenClaw on a VPS. From server preparation to connecting your favorite chat platforms, you can have everything up and running in about 30 minutes. Let’s dive into how you can reclaim control over your AI interactions.
Why a VPS is Better Than a Local Machine
Technically, you could run OpenClaw on your personal laptop. However, doing so comes with significant drawbacks. If you close your laptop or your Wi-Fi drops, your bot goes offline immediately. By using a VPS (Virtual Private Server), your AI assistant remains active in the background, ready to respond even when you are fast asleep or traveling without your computer. It provides a stable, always-on foundation that a local machine simply cannot match.
Minimum System Requirements
You don't need a supercomputer to run OpenClaw, but stability requires meeting some basic hardware benchmarks. To ensure smooth operation, your VPS should have at least 1 vCPU, 2GB of RAM, and 10GB of SSD storage. While many Linux distributions work, Ubuntu or Debian are highly recommended for the best compatibility. For this tutorial, we are using Hostinger’s VPS environment, but the steps are universal for almost any Linux-based provider with root access.
Step 1: Preparing Your Docker Environment
We utilize Docker to run OpenClaw because it simplifies the installation process. Docker acts as a container that bundles all the necessary dependencies together, so you don't have to worry about manually installing libraries or conflicting software versions.
If you are using a modern dashboard like Hostinger’s hPanel, you can find the Docker Manager directly in the interface. If you prefer the command line or are using a different provider, connect to your server via SSH and verify your Docker installation with these commands:
docker --version
docker-compose --version
If the terminal returns a "command not found" error, you will need to install Docker first. Ensuring that the Docker daemon is active and healthy is the most important prerequisite before moving to the next phase.
Step 2: Cloning the Repository and Setup
Once your server is ready, it is time to grab the source code. Start by cloning the official OpenClaw repository directly onto your server using Git:
git clone https://github.com/OpenClaw/OpenClaw.git
cd OpenClaw
OpenClaw comes with a dedicated setup script that automates the heavy lifting. Run the following command to start the build process:
./docker-setup.sh
This script handles several tasks: it creates the necessary network bridges, builds the local Docker images (ensuring you are always running the latest code for your specific architecture), and initializes the configuration files. Unlike many projects that pull pre-built images, OpenClaw builds them locally, which provides better performance and security.
Step 3: Navigating the Onboarding Wizard
As the build completes, the script will launch an interactive onboarding wizard. This is where you define how your AI assistant thinks and communicates.
First, you will be asked for the gateway type; choose "Local" to ensure the gateway runs directly on your VPS. The most critical part follows: setting up your AI provider. While OpenClaw supports multiple backends, using an Anthropic API Key is highly recommended for the best experience with Claude models.
You will need to log into your Anthropic or OpenAI account, generate a fresh API key, and paste it into the wizard. Remember, these keys are sensitive—anyone with access to them can use AI services on your tab. Ensure your billing is active on the provider's side, as a missing payment method is the most common reason for setup failure.
Step 4: Verifying the Installation
Once the setup script finishes, you need to confirm that the containers are healthy. Run this command:
docker ps
Fiber network designs you can actually rely on.
We handle the heavy lifting. From local surveys in Java & Medan to detailed FTTH grid designs, we make sure your network makes sense.
You should see openclaw-gateway listed with a status of "Up" or "Running." If the container is stuck in a restart loop, it’s time to check the logs. Use docker logs -f openclaw-gateway to see exactly what is happening under the hood. Most errors at this stage relate to invalid API keys or port conflicts.
Step 5: Accessing the Control UI
The OpenClaw dashboard is your command center. You can access it via your browser by navigating to your VPS IP address on port 18789 (e.g., http://45.123.45.67:18789).
Upon your first visit, you will be asked for a Gateway Token. This token was generated during the setup script. Even though the project is now called OpenClaw, you might still find these credentials in a directory named ~/.clawdbot/. This is a normal part of the rebranding transition. Once authenticated, you can manage settings and monitor your bot’s health from this web interface.
Step 6: Connecting to Telegram
While the dashboard is for management, the actual conversations happen on chat platforms. Telegram is the easiest to set up. First, message @BotFather on Telegram to create a new bot and receive your API token.
Then, back on your server, run the following command to link the bot:
./docker-setup.sh --telegram YOUR_BOT_TOKEN
You may need to set specific permissions via BotFather (like disabling Privacy Mode) so the bot can read messages in groups. If you enabled DM pairing, the bot will provide a code that you must approve on the server to finalize the connection.
Maintenance and Troubleshooting
Even a well-configured bot needs occasional maintenance. If your container stops unexpectedly, check for "Invalid API key" errors or check if port 18789 is being used by another service. If you update your environment variables, remember to restart the containers using:
docker-compose restart
For long-term stability, monitor your resource usage with docker stats. OpenClaw is lightweight, but it's good practice to keep an eye on memory consumption. Periodically pull the latest code and rerun the setup script to benefit from new features and security patches. By following these steps, you’ve successfully built a private, high-performance AI assistant that you truly own.