Skip to main contentSkip to navigation
[email protected]
Client AreaSupport
Hosting Mammoth
HostingMammothYour Data, Our Responsibility
Home
Solutions
Hosting Services
Store
Pricing
About
Blog
API
Contact

Stay Ahead of the Curve

Get the latest insights on cybersecurity, AI innovations, and enterprise data solutions delivered to your inbox.

Hosting Mammoth
HostingMammothEnterprise Solutions

Enterprise-grade data solutions. Hosting, recovery, cybersecurity, and AI-powered services for businesses worldwide.

[email protected]
Sun - Fri, 9:00am - 5:00pm

Services

  • Cloud Hosting
  • Data Recovery
  • Cybersecurity
  • Legal Support
  • MSP Services
  • Web Development
  • AI Services
  • Free Server Migration

Hosting

  • VPS Hosting (NVMe SSD)
  • VDS Hosting (NVMe)
  • Storage VPS (High SSD)
  • GPU Servers
  • Managed Services
  • Cloud Firewall
  • Load Balancer
  • One-Click Apps
  • n8n Hosting
  • Object Storage
  • FAQ

Company

  • Store
  • Pricing
  • About Us
  • Locations
  • Blog
  • Testimonials
  • Contact
  • Affiliate Program
  • White-Label
  • Terms of Service
  • Privacy Policy
  • Browser Cookies
  • SLA

Support

  • Client Area
  • Submit Ticket
  • Knowledge Base
  • Server Status
  • API Documentation

© 2026 Hosting Mammoth. All rights reserved.

Knowledge Base
Getting StartedAccount ManagementVPS HostingGPU ServersStorage VPSCloud FirewallLoad BalancerServer ManagementBilling & PaymentsSupport & TicketsAffiliate ProgramReseller ProgramMarketplace & Appsn8n HostingManaged ServicesServer MigrationAPI & DevelopersSecurityTroubleshootingGlossaryInstall Guides
  1. Home
  2. /
  3. Support
  4. /
  5. Install Guides
  6. /
  7. How To Install Openclaw Ubuntu
GUIDEInstall Guides

How to Install OpenClaw on Ubuntu 24.04 — Personal AI Assistant

27 min read

Quick Summary

OpenClaw is the fastest-growing self-hosted AI assistant in history, crossing 215,000 GitHub stars within months of its public release. In this guide, you will install OpenClaw on Ubuntu 24.04, connect it to multiple LLM providers (Claude, ChatGPT, and local models via Ollama), set up Telegram integration, and configure the deployment for production use with Nginx, SSL, and automatic backups.

The entire process takes about 20 minutes on a fresh VPS.

Want to skip the setup? VPS-Server.host offers one-click OpenClaw deployments on our CloudCore Professional plan. Get started here and have your personal AI assistant running in under 60 seconds.

Table of Contents

  • What is OpenClaw?
  • Why Self-Host OpenClaw?
  • Prerequisites
  • Step 1: Install Docker and Docker Compose
  • Step 2: Clone the OpenClaw Repository
  • Step 3: Configure Environment Variables
  • Step 4: Launch with Docker Compose
  • Step 5: Access the Web Interface
  • Step 6: Connect LLM Providers
  • Step 7: Set Up Telegram Integration
  • Step 8: Configure for Production
  • Step 9: Connect to Local Ollama (No API Keys Needed)
  • Advanced: Custom Tools and Plugins
  • Security Hardening
  • Updating OpenClaw
  • Troubleshooting
  • FAQ
  • Next Steps
  • What is OpenClaw?

    OpenClaw is an open-source, self-hosted AI assistant that connects to multiple large language model (LLM) providers and exposes them through a unified web interface, API, and messaging integrations. It launched in early 2026 and reached 215,000 GitHub stars faster than any developer tool in the platform's history, surpassing previous records set by projects like Ollama and Open WebUI.

    At its core, OpenClaw is a Docker-based platform that acts as a single control plane for all of your AI interactions. Instead of paying for separate subscriptions to ChatGPT, Claude, and other services, you bring your own API keys and interact with every model through one interface. But OpenClaw goes well beyond simple chat.

    What OpenClaw can do:

    • Multi-LLM conversations. Switch between Claude (Anthropic), GPT-4o (OpenAI), Gemini (Google), Mistral, and local models mid-conversation. Compare responses side-by-side.
    • Task automation. Define recurring tasks -- daily briefings, email summaries, data checks -- and OpenClaw executes them on schedule using whichever model you assign.
    • Web browsing. OpenClaw includes a built-in headless browser. Ask it to research a topic, scrape a page, monitor a competitor's pricing, or summarize a long article -- it navigates the web on your behalf.
    • File management. Upload documents, images, and datasets. OpenClaw processes them, extracts information, converts formats, and stores results in your personal knowledge base.
    • Code execution. OpenClaw runs Python and JavaScript in a sandboxed environment. Ask it to analyze data, generate charts, write scripts, or debug code, and it executes the result in real time.
    • Messaging integrations. Connect Telegram, Slack, Discord, or email. Send a message to your Telegram bot and get an AI response instantly, from any device.
    • Plugin ecosystem. Extend OpenClaw with community plugins for calendar management, home automation, financial tracking, and hundreds of other use cases.
    Why it went viral. OpenClaw hit a nerve because it solved a frustration most AI users share: vendor lock-in. People were paying $20/month for ChatGPT Plus, $20/month for Claude Pro, and still switching between tabs. OpenClaw collapsed all of that into a single self-hosted interface with no monthly fees beyond your API usage. The Telegram integration was the tipping point -- being able to message an AI assistant from your phone as naturally as texting a friend turned it from a developer tool into something everyone wanted.

    Compared to alternatives like Open WebUI (which focuses on Ollama integration) or LibreChat (which focuses on API proxy), OpenClaw distinguishes itself with its task automation engine, plugin system, and first-class mobile experience through messaging apps.

    Why Self-Host OpenClaw?

    Running OpenClaw on your own VPS provides advantages that no hosted AI service can match:

    Complete privacy. Every conversation, uploaded file, and generated response stays on your server. Nothing is sent to third parties beyond the LLM API calls themselves (which you control). For businesses handling sensitive data, this is not optional -- it is a requirement.

    Bring your own API keys. You pay only for the tokens you actually use. No monthly subscription, no per-seat pricing, no surprise charges. A typical user running Claude 3.5 Sonnet through their own API key spends $3-8 per month instead of $20 for a Pro subscription.

    Customizable behavior. Configure system prompts, model defaults, temperature settings, and response formatting exactly how you want. Create specialized assistants for different workflows -- one for coding, one for writing, one for research -- each with its own personality and tool access.

    Integration with your infrastructure. Connect OpenClaw to your existing tools: Telegram for mobile access, Slack for team channels, email for async workflows, webhooks for automation pipelines. On a VPS, you can also mount local directories, access databases, and connect to internal services.

    No rate limits. Hosted AI services throttle heavy users. With your own API keys and self-hosted interface, your only limit is the rate limit on your API tier, which you control.

    Full data ownership. Export your conversation history, knowledge base, and configuration at any time. Migrate between providers without losing anything. Your data is stored in a PostgreSQL database that you own and can back up however you choose.

    Prerequisites

    Before you begin, make sure you have the following:

    RequirementDetails
    VPSUbuntu 24.04 LTS with at least 4 vCPU, 8 GB RAM, and 50 GB storage. We recommend our CloudCore Professional plan (6 vCPU, 12 GB RAM, 100 GB NVMe) for the best experience, especially if you plan to run local models with Ollama.
    SSH accessRoot or sudo access to your server.
    Docker & Docker ComposeCovered in Step 1 below.
    Domain nameOptional but recommended for production. Required if you want SSL.
    LLM API keyAt least one of: Anthropic API key, OpenAI API key, or a local Ollama installation (free, covered in Step 9).
    Not sure which VPS plan to pick? OpenClaw itself runs comfortably on 4 GB RAM. If you also want to run Ollama with a 7B-parameter model locally, aim for 12 GB RAM. Our CloudCore Professional plan at $18.99/month covers both with room to spare. View plans.

    Step 1: Install Docker and Docker Compose

    Connect to your VPS via SSH:

    bash
    ssh root@your-server-ip

    Update the system packages:

    bash
    apt update && apt upgrade -y

    Install Docker using the official convenience script:

    bash
    curl -fsSL https://get.docker.com | sh

    Add your user to the docker group so you can run Docker commands without sudo:

    bash
    usermod -aG docker $USER

    Log out and log back in for the group change to take effect, or run:

    bash
    newgrp docker

    Verify Docker is installed and running:

    bash
    docker --version

    Expected output:

    text
    Docker version 27.x.x, build xxxxxxx

    Docker Compose is included with modern Docker installations. Verify:

    bash
    docker compose version

    Expected output:

    text
    Docker Compose version v2.x.x

    If docker compose is not available, install the plugin manually:

    bash
    apt install docker-compose-plugin -y

    Step 2: Clone the OpenClaw Repository

    Install Git if it is not already present:

    bash
    apt install git -y

    Clone the OpenClaw repository:

    bash
    git clone https://github.com/openclaw-ai/openclaw.git /opt/openclaw

    Change into the project directory:

    bash
    cd /opt/openclaw

    Check out the latest stable release:

    bash
    git checkout $(git describe --tags --abbrev=0)

    This ensures you are running a tagged release rather than the latest commit on main, which may contain experimental changes.

    Step 3: Configure Environment Variables

    Copy the example environment file:

    bash
    cp .env.example .env

    Open the file in your preferred editor:

    bash
    nano .env

    Here is a breakdown of the key variables you need to configure:

    bash
    # ============================================
    

    OpenClaw Configuration

    ============================================

    --- Security ---

    Generate a random secret key for session encryption.

    Run: openssl rand -hex 32

    SECRET_KEY=your_generated_secret_key_here

    Admin credentials for the first user account.

    [email protected] ADMIN_PASSWORD=a_strong_password_here

    --- LLM Providers ---

    Add API keys for the providers you want to use.

    You need at least one, but can add all of them.

    Anthropic (Claude)

    ANTHROPIC_API_KEY=sk-ant-api03-xxxxxxxxxxxxxxxxxxxx

    OpenAI (GPT-4o, GPT-4, GPT-3.5)

    OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxx

    Google (Gemini)

    GOOGLE_AI_API_KEY=AIzaxxxxxxxxxxxxxxxxxxxxxxxxx

    Local models via Ollama (configured in Step 9)

    OLLAMA_URL=http://host.docker.internal:11434

    --- Database ---

    Default PostgreSQL credentials. Change the password.

    POSTGRES_USER=openclaw POSTGRES_PASSWORD=change_this_to_a_strong_password POSTGRES_DB=openclaw

    Internal database URL (used by the application container).

    DATABASE_URL=postgresql://openclaw:change_this_to_a_strong_password@db:5432/openclaw

    --- Redis ---

    REDIS_URL=redis://redis:6379/0

    --- Application ---

    The URL where OpenClaw will be accessible.

    For initial setup, use your VPS IP. Change to your domain later.

    APP_URL=http://your-server-ip:3000

    Port the web interface listens on.

    PORT=3000

    --- Telegram (Optional, configured in Step 7) ---

    TELEGRAM_BOT_TOKEN= TELEGRAM_WEBHOOK_URL=

    --- File Storage ---

    Maximum upload size in megabytes.

    MAX_UPLOAD_SIZE=50

    --- Logging ---

    LOG_LEVEL=info

    Save the file (Ctrl+O, Enter, Ctrl+X in nano).

    Important notes on the configuration:

    • SECRET_KEY: Generate this with openssl rand -hex 32. Never reuse a secret key across installations.
    • ADMIN_PASSWORD: Use a strong password with at least 16 characters. You will change this through the web interface later if you want.
    • POSTGRES_PASSWORD: Must match in both POSTGRES_PASSWORD and the DATABASE_URL connection string.
    • OLLAMA_URL: The host.docker.internal hostname lets the Docker container reach services running on the host machine. If Ollama is not installed yet, leave this as-is -- it will simply be unused until you set it up in Step 9.

    Step 4: Launch with Docker Compose

    From the /opt/openclaw directory, start all services:

    bash
    docker compose up -d

    This pulls the required images and starts four containers:

    ContainerPurposeDefault Port
    openclaw-webThe main web application and API server3000
    openclaw-workerBackground task runner for scheduled jobs, web browsing, and code execution-
    openclaw-dbPostgreSQL 16 database for conversations, users, and configuration5432 (internal)
    openclaw-redisRedis for session management, caching, and task queues6379 (internal)
    For reference, here is the docker-compose.yml that ships with OpenClaw:

    yaml
    services:
      web:
        image: ghcr.io/openclaw-ai/openclaw:latest
        container_name: openclaw-web
        restart: unless-stopped
        ports:
          - "${PORT:-3000}:3000"
        env_file:
          - .env
        depends_on:
          db:
            condition: service_healthy
          redis:
            condition: service_started
        volumes:
          - openclaw-uploads:/app/uploads
          - openclaw-plugins:/app/plugins
        extra_hosts:
          - "host.docker.internal:host-gateway"

    worker: image: ghcr.io/openclaw-ai/openclaw:latest container_name: openclaw-worker restart: unless-stopped command: ["node", "dist/worker.js"] env_file: - .env depends_on: db: condition: service_healthy redis: condition: service_started volumes: - openclaw-uploads:/app/uploads - openclaw-plugins:/app/plugins extra_hosts: - "host.docker.internal:host-gateway"

    db: image: postgres:16-alpine container_name: openclaw-db restart: unless-stopped environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} volumes: - openclaw-pgdata:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"] interval: 5s timeout: 5s retries: 5

    redis: image: redis:7-alpine container_name: openclaw-redis restart: unless-stopped volumes: - openclaw-redis-data:/data

    volumes: openclaw-pgdata: openclaw-redis-data: openclaw-uploads: openclaw-plugins:

    Check that all containers are running:

    bash
    docker compose ps

    Expected output:

    text
    NAME               IMAGE                                 STATUS          PORTS
    openclaw-web       ghcr.io/openclaw-ai/openclaw:latest   Up 30 seconds   0.0.0.0:3000->3000/tcp
    openclaw-worker    ghcr.io/openclaw-ai/openclaw:latest   Up 30 seconds
    openclaw-db        postgres:16-alpine                    Up 30 seconds   5432/tcp
    openclaw-redis     redis:7-alpine                        Up 30 seconds   6379/tcp

    Watch the logs for any startup errors:

    bash
    docker compose logs -f web

    You should see a message like:

    text
    [INFO] OpenClaw server started on port 3000
    [INFO] Database migrations applied successfully
    [INFO] Ready to accept connections

    Press Ctrl+C to stop following the logs.

    Step 5: Access the Web Interface

    Open your browser and navigate to:

    text
    http://your-server-ip:3000

    You will see the OpenClaw login screen. Sign in with the credentials you set in the .env file:

    • Email: The value of ADMIN_EMAIL
    • Password: The value of ADMIN_PASSWORD
    On first login, OpenClaw presents a setup wizard that walks you through:

  • Profile setup. Set your display name and avatar.
  • Default model selection. Choose which LLM to use by default (you can always switch per conversation).
  • Quick test. Send a test message to verify your API keys work.
  • Optional integrations. Enable Telegram, Slack, or other connections.
  • Complete the wizard or skip it -- you can configure everything later from the Settings panel.

    The main interface is organized into:

    • Chat. The primary conversation view. Start new threads, switch models, upload files.
    • Tasks. Schedule and monitor recurring AI tasks.
    • Knowledge. Upload documents to build a searchable knowledge base that grounds your AI conversations.
    • Tools. Browse and enable built-in tools (web search, code execution, image generation) and community plugins.
    • Settings. Manage API keys, users, integrations, and system configuration.

    Step 6: Connect LLM Providers

    If you already set API keys in the .env file, your providers should appear automatically in Settings > Providers. You can also add or update keys through the web interface.

    Anthropic (Claude)

  • Go to Settings > Providers > Anthropic.
  • Enter your API key (get one at console.anthropic.com).
  • Click Test Connection. You should see a green checkmark and the list of available models (Claude 4 Sonnet, Claude 4 Opus, Claude 3.5 Haiku, etc.).
  • Click Save.
  • OpenAI (GPT-4o)

  • Go to Settings > Providers > OpenAI.
  • Enter your API key (get one at platform.openai.com).
  • Click Test Connection. Available models include GPT-4o, GPT-4o-mini, o3, o4-mini, and others.
  • Click Save.
  • Local Models via Ollama

    If you want to use completely free, locally-running models, see Step 9 below.

    Testing Your Providers

    Verify each provider works by opening a new chat, selecting the model from the dropdown, and sending a simple prompt:

    text
    What model are you, and what is today's date?

    Each provider should respond with its identity. This confirms the API key, network connectivity, and model routing are all working.

    You can also test from the command line:

    bash
    curl -s http://localhost:3000/api/v1/chat/completions \
      -H "Authorization: Bearer $(cat /opt/openclaw/.env | grep SECRET_KEY | cut -d= -f2)" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "claude-sonnet-4-20250514",
        "messages": [{"role": "user", "content": "Hello, what model are you?"}]
      }' | jq .choices[0].message.content

    Step 7: Set Up Telegram Integration

    The Telegram integration is what made OpenClaw go viral. It turns your self-hosted AI into a personal assistant you can message from your phone, anywhere.

    Create a Telegram Bot

  • Open Telegram and search for @BotFather.
  • Send the command /newbot.
  • Choose a name for your bot (e.g., "My AI Assistant").
  • Choose a username (e.g., my_openclaw_bot). It must end in bot.
  • BotFather will respond with a token like 7123456789:AAH0xjk9fZ3Kq2Pm.... Copy it.
  • Configure OpenClaw

    Edit the environment file:

    bash
    nano /opt/openclaw/.env

    Set the Telegram variables:

    bash
    TELEGRAM_BOT_TOKEN=7123456789:AAH0xjk9fZ3Kq2Pm_your_full_token_here
    TELEGRAM_WEBHOOK_URL=https://yourdomain.com/api/v1/telegram/webhook

    Note: The webhook URL must be HTTPS. If you have not set up SSL yet (covered in Step 8), you can use Telegram's polling mode instead by adding:

    bash
    TELEGRAM_MODE=polling

    Restart the services to pick up the new configuration:

    bash
    cd /opt/openclaw && docker compose restart

    Test the Bot

    Open Telegram and send a message to your bot:

    text
    Hello, are you there?

    The bot should respond within a few seconds using your default LLM provider. You can switch models by sending:

    text
    /model claude-sonnet

    Other useful Telegram commands:

    CommandDescription
    /model <name>Switch the active LLM model
    /resetClear conversation history
    /task <description>Create a new scheduled task
    /statusShow system status and active model
    /helpList all available commands
    You can send images, documents, and voice messages to the bot. It processes them using the connected LLM's multimodal capabilities.

    Step 8: Configure for Production

    Running on port 3000 over HTTP is fine for testing. For production, you need a reverse proxy with SSL, automatic restarts, and database backups.

    Set Up Nginx Reverse Proxy with SSL

    Install Nginx and Certbot:

    bash
    apt install nginx certbot python3-certbot-nginx -y

    Create the Nginx configuration file:

    bash
    nano /etc/nginx/sites-available/openclaw

    Paste the following configuration, replacing openclaw.yourdomain.com with your actual domain:

    nginx
    # Redirect HTTP to HTTPS
    server {
        listen 80;
        listen [::]:80;
        server_name openclaw.yourdomain.com;

    location /.well-known/acme-challenge/ { root /var/www/html; }

    location / { return 301 https://$host$request_uri; } }

    Main HTTPS server block

    server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name openclaw.yourdomain.com;

    # SSL certificates (managed by Certbot) ssl_certificate /etc/letsencrypt/live/openclaw.yourdomain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/openclaw.yourdomain.com/privkey.pem;

    # SSL hardening ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384; ssl_prefer_server_ciphers off; ssl_session_cache shared:SSL:10m; ssl_session_timeout 1d; ssl_session_tickets off;

    # HSTS add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;

    # Security headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    # Max upload size (match OpenClaw's MAX_UPLOAD_SIZE) client_max_body_size 50M;

    # Proxy to OpenClaw location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;

    # Timeouts for long-running LLM requests proxy_read_timeout 300s; proxy_send_timeout 300s; proxy_connect_timeout 60s;

    # Buffering settings for streaming responses proxy_buffering off; proxy_cache off; }

    # Health check endpoint location /api/v1/health { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; access_log off; } }

    Enable the site and disable the default:

    bash
    ln -s /etc/nginx/sites-available/openclaw /etc/nginx/sites-enabled/
    rm -f /etc/nginx/sites-enabled/default

    Test the Nginx configuration:

    bash
    nginx -t

    Obtain an SSL certificate:

    bash
    certbot --nginx -d openclaw.yourdomain.com --non-interactive --agree-tos -m [email protected]

    Restart Nginx:

    bash
    systemctl restart nginx

    Update the APP_URL in your .env file:

    bash
    sed -i 's|APP_URL=.*|APP_URL=https://openclaw.yourdomain.com|' /opt/openclaw/.env

    Also update the Telegram webhook URL if applicable:

    bash
    sed -i 's|TELEGRAM_WEBHOOK_URL=.*|TELEGRAM_WEBHOOK_URL=https://openclaw.yourdomain.com/api/v1/telegram/webhook|' /opt/openclaw/.env
    sed -i '/TELEGRAM_MODE=polling/d' /opt/openclaw/.env

    Restart OpenClaw to apply the changes:

    bash
    cd /opt/openclaw && docker compose restart

    Set Up Automatic Restarts with systemd

    Docker's restart: unless-stopped policy handles container crashes, but to ensure the entire stack starts on server boot, create a systemd service:

    bash
    nano /etc/systemd/system/openclaw.service
    ini
    [Unit]
    Description=OpenClaw AI Assistant
    Requires=docker.service
    After=docker.service

    [Service] Type=oneshot RemainAfterExit=yes WorkingDirectory=/opt/openclaw ExecStart=/usr/bin/docker compose up -d ExecStop=/usr/bin/docker compose down TimeoutStartSec=120

    [Install] WantedBy=multi-user.target

    Enable and start the service:

    bash
    systemctl daemon-reload
    systemctl enable openclaw.service

    Configure Database Backups

    Create a backup script:

    bash
    nano /opt/openclaw/backup.sh
    bash
    #!/bin/bash
    

    OpenClaw database backup script

    Keeps 7 daily backups

    BACKUP_DIR="/opt/openclaw/backups" TIMESTAMP=$(date +%Y%m%d_%H%M%S) BACKUP_FILE="${BACKUP_DIR}/openclaw_${TIMESTAMP}.sql.gz"

    mkdir -p "$BACKUP_DIR"

    Dump the database and compress it

    docker exec openclaw-db pg_dump -U openclaw openclaw | gzip > "$BACKUP_FILE"

    if [ $? -eq 0 ]; then echo "[$(date)] Backup created: $BACKUP_FILE" else echo "[$(date)] ERROR: Backup failed!" >&2 exit 1 fi

    Remove backups older than 7 days

    find "$BACKUP_DIR" -name "openclaw_*.sql.gz" -mtime +7 -delete

    echo "[$(date)] Cleanup complete. Current backups:" ls -lh "$BACKUP_DIR"

    Make it executable and set up a daily cron job:

    bash
    chmod +x /opt/openclaw/backup.sh
    bash
    crontab -e

    Add the following line to run backups daily at 3:00 AM:

    text
    0 3   * /opt/openclaw/backup.sh >> /var/log/openclaw-backup.log 2>&1

    Run the backup script once to verify:

    bash
    /opt/openclaw/backup.sh

    You should see output confirming the backup was created in /opt/openclaw/backups/.

    Step 9: Connect to Local Ollama (No API Keys Needed)

    Ollama lets you run large language models locally on your VPS. Combined with OpenClaw, you get a fully self-contained AI assistant with zero ongoing API costs. This is ideal for privacy-sensitive deployments or for experimenting with open-weight models.

    Install Ollama

    bash
    curl -fsSL https://ollama.com/install.sh | sh

    Verify the installation:

    bash
    ollama --version

    Pull a Model

    For a good balance of quality and resource usage, start with Llama 3.1 8B:

    bash
    ollama pull llama3.1:8b

    This downloads approximately 4.7 GB. On a VPS with 12 GB RAM, this model runs comfortably and leaves headroom for OpenClaw's services.

    For a smaller, faster option:

    bash
    ollama pull phi3:mini

    For the most capable open model that fits in 12 GB RAM:

    bash
    ollama pull llama3.1:8b-instruct-q8_0

    Verify Ollama is Running

    bash
    curl http://localhost:11434/api/tags | jq .models[].name

    Expected output:

    text
    "llama3.1:8b"

    Connect OpenClaw to Ollama

    If you set OLLAMA_URL=http://host.docker.internal:11434 in your .env file during Step 3, OpenClaw is already configured to reach Ollama. Restart the services to ensure the connection is active:

    bash
    cd /opt/openclaw && docker compose restart

    In the OpenClaw web interface, go to Settings > Providers > Ollama. You should see your installed models listed automatically. Click Test Connection to confirm.

    Now in any chat, select a local model from the model dropdown. Conversations using Ollama models never leave your server -- not a single byte is sent to any external API.

    Make Ollama Start on Boot

    Ollama installs its own systemd service by default. Verify it is enabled:

    bash
    systemctl is-enabled ollama

    If it says disabled, enable it:

    bash
    systemctl enable ollama

    Advanced: Custom Tools and Plugins

    OpenClaw's plugin system lets you extend the assistant with custom tools. Plugins are defined as JSON manifests with associated handler code.

    Plugin Structure

    Each plugin lives in a directory under /opt/openclaw/plugins/ (which is volume-mounted into the container). A basic plugin looks like this:

    text
    plugins/
      my-weather-tool/
        manifest.json
        handler.js

    manifest.json:

    json
    {
      "id": "my-weather-tool",
      "name": "Weather Lookup",
      "description": "Get current weather for any city",
      "version": "1.0.0",
      "tools": [
        {
          "name": "get_weather",
          "description": "Returns the current weather for a given city name",
          "parameters": {
            "type": "object",
            "properties": {
              "city": {
                "type": "string",
                "description": "The city name, e.g. 'London' or 'Tokyo'"
              }
            },
            "required": ["city"]
          }
        }
      ]
    }

    handler.js:

    javascript
    module.exports = {
      async get_weather({ city }) {
        const response = await fetch(
          https://wttr.in/${encodeURIComponent(city)}?format=j1
        );
        const data = await response.json();
        const current = data.current_condition[0];

    return { city, temperature_c: current.temp_C, feels_like_c: current.FeelsLikeC, condition: current.weatherDesc[0].value, humidity: current.humidity, wind_kph: current.windspeedKmph, }; }, };

    After adding a plugin, restart the worker container:

    bash
    docker compose restart worker

    The new tool will appear in Tools > Custom Plugins in the web interface. Enable it, and the LLM will automatically invoke it when relevant -- for example, if you ask "What is the weather in Berlin?" it will call get_weather with {"city": "Berlin"}.

    Community Plugins

    The OpenClaw community maintains a plugin registry at plugins.openclaw.ai. Popular plugins include:

    • Calendar -- Connect to Google Calendar or CalDAV to check and create events.
    • Home Assistant -- Control smart home devices through natural language.
    • Finance -- Track expenses, fetch stock prices, monitor crypto portfolios.
    • Image Generation -- Route prompts to Stable Diffusion, DALL-E, or Flux.
    Install a community plugin by cloning it into the plugins directory:

    bash
    cd /opt/openclaw/plugins
    git clone https://github.com/openclaw-plugins/calendar-tool.git
    docker compose restart worker

    Security Hardening

    A self-hosted AI assistant stores sensitive conversations. Take these steps to secure your deployment.

    Change Default Credentials

    If you used simple credentials during initial setup, change them now:

  • Log into the web interface.
  • Go to Settings > Account > Security.
  • Update your password to a strong, unique passphrase.
  • Enable Two-Factor Authentication (2FA) using an authenticator app (TOTP). Scan the QR code and save the backup codes.
  • Restrict Network Access with UFW

    Configure the firewall to allow only necessary traffic:

    bash
    ufw default deny incoming
    ufw default allow outgoing
    ufw allow 22/tcp comment "SSH"
    ufw allow 80/tcp comment "HTTP (redirect to HTTPS)"
    ufw allow 443/tcp comment "HTTPS"
    ufw enable

    Verify the rules:

    bash
    ufw status verbose

    Port 3000 is no longer exposed to the internet since Nginx proxies all traffic over 443. The Docker containers communicate internally on the Docker bridge network.

    Disable Direct Port Exposure

    By default, the docker-compose.yml maps port 3000 to the host. Once Nginx is configured, bind it to localhost only. Edit docker-compose.yml:

    Change:

    yaml
    ports:
      - "${PORT:-3000}:3000"

    To:

    yaml
    ports:
      - "127.0.0.1:${PORT:-3000}:3000"

    Restart the stack:

    bash
    cd /opt/openclaw && docker compose up -d

    Enable Nginx Rate Limiting

    Add rate limiting to your Nginx configuration to prevent brute-force attacks on the login endpoint. Add this to the http block in /etc/nginx/nginx.conf:

    nginx
    limit_req_zone $binary_remote_addr zone=openclaw_login:10m rate=5r/m;

    Then in your site configuration, add a location block for the login API:

    nginx
    location /api/v1/auth/login {
        limit_req zone=openclaw_login burst=3 nodelay;
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    Reload Nginx:

    bash
    systemctl reload nginx

    Keep the System Updated

    Set up unattended security updates for the host OS:

    bash
    apt install unattended-upgrades -y
    dpkg-reconfigure -plow unattended-upgrades

    Updating OpenClaw

    OpenClaw releases updates frequently. Updating is straightforward with Docker.

    Backup Before Updating

    Always back up before an update:

    bash
    /opt/openclaw/backup.sh

    Pull and Restart

    bash
    cd /opt/openclaw
    docker compose pull
    docker compose up -d

    Docker pulls the latest images and recreates the containers. Your data persists in the named volumes (openclaw-pgdata, openclaw-redis-data, openclaw-uploads, openclaw-plugins).

    Verify the Update

    Check the running version:

    bash
    docker exec openclaw-web cat /app/version.txt

    Or check through the web interface at Settings > About.

    Review the logs for any migration messages:

    bash
    docker compose logs --tail=50 web

    Rolling Back

    If an update causes issues, roll back to the previous image:

    bash
    cd /opt/openclaw
    docker compose down
    docker compose pull ghcr.io/openclaw-ai/openclaw:v1.x.x  # specific version tag
    docker compose up -d

    Check the OpenClaw releases page for version tags and changelogs.

    Troubleshooting

    Container Won't Start

    Check the logs for the failing container:

    bash
    docker compose logs web
    docker compose logs db

    Common causes:

    • Port conflict. Another service is using port 3000. Check with ss -tlnp | grep 3000 and either stop the conflicting service or change the PORT in .env.
    • Database password mismatch. Ensure POSTGRES_PASSWORD in .env matches the password in DATABASE_URL. If you changed the password after the database was first created, you need to reset it inside the container: docker exec -it openclaw-db psql -U openclaw -c "ALTER USER openclaw PASSWORD 'new_password';".
    • Insufficient memory. Run free -h to check available RAM. OpenClaw needs at least 2 GB free. If memory is tight, consider upgrading your VPS.

    Can't Connect to LLM Provider

    bash
    # Test Anthropic connectivity from inside the container
    docker exec openclaw-web curl -s https://api.anthropic.com/v1/messages \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2023-06-01" \
      -H "content-type: application/json" \
      -d '{"model":"claude-sonnet-4-20250514","max_tokens":10,"messages":[{"role":"user","content":"Hi"}]}' | head -c 200

    Common causes:

    • Invalid API key. Verify the key is correct and has not expired.
    • Network restrictions. Some VPS providers block outbound HTTPS by default. Check with curl -I https://api.anthropic.com from the host.
    • Rate limiting. If you see 429 errors, you have exceeded your API tier's rate limit. Wait or upgrade your API plan.

    Telegram Bot Not Responding

  • Verify the bot token is correct by calling the Telegram API directly:
  • bash
    curl "https://api.telegram.org/bot<YOUR_TOKEN>/getMe"

    You should see your bot's details in the response.

  • Check if the webhook is registered (if using webhook mode):
  • bash
    curl "https://api.telegram.org/bot<YOUR_TOKEN>/getWebhookInfo"

  • If the webhook URL is wrong or SSL is not configured, switch to polling mode by adding TELEGRAM_MODE=polling to .env and restarting.
  • Check the worker logs for Telegram errors:
  • bash
    docker compose logs worker | grep -i telegram

    High Memory Usage

    Check per-container memory consumption:

    bash
    docker stats --no-stream

    If the worker container is using excessive memory, it may be running too many concurrent tasks. Limit concurrency in .env:

    bash
    WORKER_CONCURRENCY=2

    If Ollama is consuming too much RAM, try a smaller model (phi3:mini instead of llama3.1:8b) or set a memory limit:

    bash
    OLLAMA_MAX_MEMORY=4G

    Database Connection Errors

    If you see ECONNREFUSED or connection refused errors for the database:

    bash
    # Check if the database container is healthy
    docker inspect openclaw-db --format='{{.State.Health.Status}}'

    Check database logs

    docker compose logs db

    Manually test the connection

    docker exec openclaw-db pg_isready -U openclaw

    If the database volume is corrupted, restore from your latest backup:

    bash
    # Stop the stack
    cd /opt/openclaw && docker compose down

    Remove the corrupted volume

    docker volume rm openclaw_openclaw-pgdata

    Start the database only

    docker compose up -d db

    Wait for it to be healthy

    sleep 10

    Restore from backup

    gunzip < /opt/openclaw/backups/openclaw_LATEST.sql.gz | docker exec -i openclaw-db psql -U openclaw openclaw

    Start the rest

    docker compose up -d

    FAQ

    Is OpenClaw free to use?

    Yes. OpenClaw is open source under the Apache 2.0 license. There are no license fees, subscription charges, or usage limits imposed by the software. Your only costs are the VPS hosting (starting at $6.99/month on VPS-Server.host) and any LLM API usage. If you run local models through Ollama, there are zero API costs.

    Which LLM provider gives the best results?

    It depends on your use case. Claude (Anthropic) excels at writing, analysis, and following complex instructions. GPT-4o (OpenAI) is strong at coding and multimodal tasks. Local models like Llama 3.1 8B are surprisingly capable for general conversation and are completely free. Most users configure multiple providers and switch depending on the task. OpenClaw makes it easy to compare by letting you regenerate any response with a different model.

    Is there a mobile app?

    OpenClaw does not have a native mobile app, but you do not need one. The web interface is fully responsive and works well in mobile browsers. You can add it to your home screen as a PWA (Progressive Web App) for an app-like experience. The Telegram integration is arguably better than a dedicated app because it works natively within a messaging app you already use, with full notification support and no extra installation.

    How much does it cost to run OpenClaw per month?

    The total cost breaks down into two parts. The VPS hosting is a fixed cost -- a CloudCore Professional plan at VPS-Server.host runs $18.99/month and provides plenty of resources for OpenClaw plus Ollama. API costs vary by usage: a moderate user making 50-100 queries per day with Claude Sonnet spends roughly $3-8/month on API fees. If you rely entirely on local models through Ollama, the API cost is $0. Compared to a $20/month ChatGPT Plus subscription, self-hosting is both cheaper and more capable.

    Where is my data stored?

    All data is stored on your VPS in a PostgreSQL database managed by Docker. Conversation history, uploaded files, user accounts, and configuration all live in Docker volumes on your server's disk. Nothing is stored by OpenClaw on any external server. The only external communication happens when you send a prompt to a cloud LLM provider (Anthropic, OpenAI, etc.), and even then, the providers' data retention policies apply only to the individual API call, not to your full conversation history.

    How does OpenClaw compare to ChatGPT Plus?

    ChatGPT Plus gives you access to one provider (OpenAI) through a polished interface for $20/month. OpenClaw gives you access to every major provider through your own interface for the cost of a VPS plus API usage. The key differences: OpenClaw supports multiple LLMs in one interface, stores data on your server, offers Telegram/Slack integration, includes task automation and code execution, and has a plugin system. ChatGPT Plus has the advantage of zero setup and a native mobile app. For anyone who values privacy, multi-model access, or customization, OpenClaw is the clear choice.

    Next Steps

    Your OpenClaw installation is running and secured. Here are ways to get more out of it:

    • Install additional Ollama models. Try ollama pull codellama:13b for a coding-focused model or ollama pull mixtral:8x7b if you have 32+ GB RAM for near-GPT-4 quality at zero API cost.
    • Set up monitoring. Install Uptime Kuma on the same VPS to monitor OpenClaw's /api/v1/health endpoint and get alerts if it goes down.
    • Automate backups to off-site storage. Extend the backup script to upload to an S3-compatible bucket using aws s3 cp or rclone. This protects you against VPS-level failures.
    • Explore the task scheduler. Set up a daily morning briefing that summarizes your email, calendar, and news. Configure it under Tasks > New Task in the web interface.
    • Join the community. The OpenClaw Discord and GitHub Discussions are active and welcoming. Share your plugins, report bugs, and get help from other self-hosters.

    Need a VPS for OpenClaw? Our CloudCore Professional plan includes 6 vCPU, 12 GB RAM, and 100 GB NVMe SSD -- everything you need to run OpenClaw with Ollama at peak performance. Deploy Ubuntu 24.04 in under 60 seconds and follow this guide to have your personal AI assistant running today. Get started now.

    Was this article helpful?

    ← Back to Install GuidesBrowse all categories →

    Still have questions?

    Contact Support →Submit a Ticket