Deploy OpenClaw on Hetzner Cloud

Run the self-hosted OpenClaw AI agent on a Hetzner Cloud Server. This guide walks you through creating an Ubuntu server on Hetzner Cloud, adding your SSH key, installing Node.js 22+ and OpenClaw via the one-line installer, and running it as a systemd service. Hetzner’s European datacenters (Germany, Finland) and strong price-to-performance (CX11 from around €4/month) make it a popular choice for 24/7 OpenClaw hosting, especially for users who prefer EU-based infrastructure.

📘 Quick path: For the fastest setup on any Linux server, use the Quick Start Guide. This page is the full Hetzner-specific reference. Other VPS options: AWS EC2, DigitalOcean, Linode.

1. Overview

Hetzner Cloud offers Linux virtual servers (Cloud Servers) with straightforward pricing and a simple Cloud Console. OpenClaw runs on any server that supports Node.js 22+; we recommend Ubuntu 22.04 LTS. This guide covers:

  • Creating a Cloud Server (Ubuntu 22.04, CX11 from ~€4/mo or CX21 for more headroom)
  • Adding your SSH key and choosing a location (Falkenstein, Nuremberg, Helsinki)
  • Firewall: SSH only; do not expose the OpenClaw gateway port (1618) to the internet
  • Connecting via SSH and installing Node.js 22+ and OpenClaw
  • Running OpenClaw as a systemd service for 24/7 operation
  • Optional: add swap on the smallest plan to reduce OOM risk
  • Common issues and links to troubleshooting and security best practices

2. Prerequisites

  • Hetzner Cloud account - Sign up at hetzner.com/cloud. You’ll need a payment method; pricing is in euros (EUR).
  • SSH key - Generate or use an existing SSH key pair. Add the public key in the Cloud Console under Security → SSH Keys (or during server creation). You need the private key on your local machine to connect.
  • LLM API key - At least one: Anthropic Claude, OpenAI, DeepSeek, or Ollama (local).
  • Optional: A messaging app account for your first channel - e.g. Telegram, Discord, WhatsApp.

3. Create a Cloud Server

3.1 Choose image and type

  • In the Hetzner Cloud Console, create a new project if needed, then go to Servers → Add Server.
  • Location: Choose a datacenter: Falkenstein (FSN), Nuremberg (NBG), or Helsinki (HEL). Pick one close to you or your users for lower latency.
  • Image: Select Ubuntu 22.04 (or 24.04 LTS when available). Avoid older or non-LTS versions.
  • Type: Shared vCPU (Standard) is sufficient. CX11 (2 GB RAM, 2 vCPU, 20 GB) starts at around €4/month and is adequate for a single user or light automation. CX21 (4 GB RAM, 2 vCPU, 40 GB) at around €5–6/month is recommended for production or multiple channels and skills.
  • Authentication: Select your SSH key (or add a new one in the Security tab). Prefer SSH key over root password for security.
  • Name: e.g. openclaw.

3.2 Firewall (critical for security)

Do not open the OpenClaw gateway port (1618) to the internet. The gateway should bind to 127.0.0.1 on the server; you access the dashboard or CLI via SSH port forwarding, Tailscale, or another VPN.

  • Hetzner Cloud Firewall (optional but recommended): Under Firewalls, create a firewall. Allow SSH (22) from your IP only (or a narrow range). Do not add a rule for port 1618. Attach the firewall to your server.
  • On-server UFW: After first login you can run sudo ufw allow 22, sudo ufw enable. Never ufw allow 1618 for the public interface. See Security Best Practices and Network Isolation.

Click Create & buy now. Wait for the server to be created and note its public IPv4 address.

4. Connect via SSH

From your local machine (replace with your key path and server IP):

ssh root@YOUR_SERVER_IP

If you use a non-root user or a specific key:

ssh -i ~/.ssh/your_private_key root@YOUR_SERVER_IP

Hetzner’s default Ubuntu image uses root for initial login. You can create a sudo user later if you prefer.

5. Install Node.js 22+ and OpenClaw

On the server (Ubuntu 22.04), install Node.js 22+ if not present, then run the official one-line installer:

# Optional: install Node.js 22 via NodeSource (Ubuntu/Debian)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs

# Install OpenClaw (installs Node 22 if needed and runs onboarding)
curl -fsSL https://openclaw.ai/install.sh | bash

The script will create ~/.openclaw and may start the onboarding wizard. If not, run:

openclaw setup

Complete the wizard: choose an LLM provider, add your API key, and optionally add your first channel (e.g. Telegram). See the Quick Start Guide and Post-installation setup for details.

6. (Optional) Add swap on CX11

Servers with 2 GB RAM can occasionally hit out-of-memory under load. Adding a 1 GB swap file helps:

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Verify with free -h. For CX21 (4 GB) or larger, swap is optional.

7. Run OpenClaw as a systemd service

To keep OpenClaw running after you disconnect and to start it on reboot:

# Install the systemd unit (run as the user that runs OpenClaw)
sudo openclaw service install --systemd

# Enable and start the service
sudo systemctl enable openclaw
sudo systemctl start openclaw

# Check status
sudo systemctl status openclaw
openclaw status

View logs: journalctl -u openclaw -f or openclaw logs. Ensure the gateway is bound to 127.0.0.1 only; see Security Best Practices.

8. Cost and server sizing

  • CX11 (~€4/month, 2 GB RAM): Good for trying OpenClaw or light personal use. Add swap (see above) to reduce OOM risk.
  • CX21 (~€5–6/month, 4 GB RAM): Recommended for production, multiple channels, or several ClawHub skills. More stable under load.
  • Hetzner pricing is monthly and in EUR; check current prices in the Hetzner Cloud pricing section.
  • For a cost comparison across providers, see our VPS comparison and cost calculator.

9. Common issues

Issue Solution
openclaw command not found Ensure the install script added the binary to your PATH (e.g. ~/.local/bin or ~/.openclaw/bin). Add to ~/.bashrc and run source ~/.bashrc or re-connect via SSH. See Installation Errors.
Node.js version too old OpenClaw requires Node.js 22+. Run node -v. Install Node 22+ via NodeSource (see above) or nodejs.org, then re-run the installer.
Cannot connect via SSH Check that your server is running in the Cloud Console and that your firewall or Cloud Firewall allows SSH (port 22) from your IP. Verify your SSH key is added and key permissions chmod 400 your_key. Use the IP from the Hetzner console.
Gateway won't start Ensure port 1618 is free and gateway binds to 127.0.0.1. Run openclaw doctor and see Gateway Issues.
Out of memory (OOM) On CX11 (2 GB), add swap (see section 6) or upgrade to CX21 (4 GB). Reduce concurrent usage or number of skills if needed.

For more fixes, see the full Troubleshooting Guide.

10. Best practices

  • Security: Follow our Security Best Practices. Never expose the OpenClaw gateway port (1618) to the internet; use SSH tunneling, Tailscale, or a VPN for remote access.
  • Updates: Regularly update OpenClaw. After upgrading, restart: sudo systemctl restart openclaw.
  • Backups: Back up ~/.openclaw (config and credentials). Hetzner offers snapshot/backup options; use them or your own backup script. Do not commit credentials to version control.
  • Post-install: Run through the Security Checklist after setup.

11. Next steps

Related resources