Deploy Openclaw on Fly.io

Image
Table of contents: [Show]

Quick Start

Deploy your Openclaw Gateway to Fly.io in minutes with persistent storage and automatic HTTPS. This guide walks you through the complete setup.

Deploy Openclaw on Fly.io

Prerequisites

  • Fly.io account (sign up)
  • Fly CLI installed: curl -L https://fly.io/install.sh | sh
  • Git

Step 1: Create the Fly App and Volume

Clone the Openclaw repository and create a new Fly application with a persistent volume for your state:

# Clone the repo
git clone https://github.com/Openclaw/Openclaw.git
cd Openclaw

# Create a new Fly app (choose your own name)
fly apps create my-Openclaw

# Create a persistent volume (1GB is usually enough)
fly volumes create Openclaw_data --size 1 --region iad

Tip: Choose a region close to you: lhr for London, iad for Virginia, or sjc for San Jose.

Step 2: Configure fly.toml

Create a fly.toml file in your project root:

app = "my-Openclaw"  # Replace with your app name
primary_region = "iad"

[build]
dockerfile = "Dockerfile"

[env]
NODE_ENV = "production"
Openclaw_PREFER_PNPM = "1"
Openclaw_STATE_DIR = "/data"
NODE_OPTIONS = "--max-old-space-size=1536"

[processes]
app = "node dist/index.js gateway --allow-unconfigured --port 3000 --bind lan"

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = false
auto_start_machines = true
min_machines_running = 1
processes = ["app"]

[[vm]]
size = "shared-cpu-2x"
memory = "2048mb"

[mounts]
source = "Openclaw_data"
destination = "/data"

Step 3: Set Secrets

Generate a random token for your Gateway and set your model provider keys:

# Required: Gateway token (for non-loopback binding)
fly secrets set Openclaw_GATEWAY_TOKEN=$(openssl rand -hex 32)

# Model provider API keys
fly secrets set ANTHROPIC_API_KEY=sk-ant-...

# Channel tokens (e.g., Discord)
fly secrets set DISCORD_BOT_TOKEN=MTQ...
VPS Hosting for Openclaw

Step 4: Deploy

Deploy your application:

fly deploy

Once deployed, your Gateway will be available at https://my-Openclaw.fly.dev.

Step 5: Connect Your Client

Pair your device with the deployed Gateway:

# On your local machine
Openclaw devices pair https://my-Openclaw.fly.dev

Then approve the device from your Fly.io logs or use a pre-configured allowlist.

Troubleshooting & Best Practices

  • Volume persistence: The /data mount ensures your state survives restarts
  • Auto-start: Machines automatically start on request; set min_machines_running = 1 to keep it always-on
  • Logs: View with fly logs
  • SSH: Access with fly ssh console
  • Scaling: Upgrade VM size in fly.toml if needed

Your Openclaw Gateway is now running on Fly.io with automatic deployments, HTTPS, and global edge routing.