Self-Host OpenClaw on Fly.io
Fly.io is one of the simplest paths to self-hosting OpenClaw. It handles Docker builds, TLS certificates, volume persistence, and global networking out of the box. You configure a single fly.toml file, run fly deploy, and get a running instance with a public URL in minutes.
This guide walks through the full setup, from installing flyctl to accessing your running OpenClaw instance.
Quick Path
For users already familiar with Fly.io:
- Clone the OpenClaw repo and
cdinto it fly apps create openclaw(pick your preferred region)fly volumes create openclaw_data --size 1 --region your-region- Create
fly.tomlwith shared-cpu-2x, 2048 MB RAM, volume mount at/data fly secrets set OPENCLAW_GATEWAY_TOKEN=... ANTHROPIC_API_KEY=...fly deployfly ssh consoleto create/data/openclaw.jsonconfig- Access at
https://openclaw.fly.dev
Prerequisites
- A Fly.io account (free to create, credit card required for deployment)
- The
flyctlCLI installed - Git installed
- An Anthropic API key
Install and authenticate flyctl:
Step 1: Clone the OpenClaw Repository
Step 2: Create the Fly.io Application
Create a new application on Fly.io. The name must be globally unique:
If openclaw is taken, choose a different name (e.g., openclaw-yourname) and use that name throughout this guide.
Select a region when prompted. Choose one close to your location for the lowest latency. Common choices:
| Region Code | Location |
|---|---|
iad | Virginia, US |
ord | Chicago, US |
lhr | London, UK |
ams | Amsterdam, NL |
nrt | Tokyo, JP |
syd | Sydney, AU |
Step 3: Create a Persistent Volume
OpenClaw stores its state (sessions, configuration, workspace data) on disk. A Fly.io volume provides persistent storage that survives deployments and restarts:
This creates a 1 GB volume. Adjust the size if you anticipate storing large codebases or many sessions. The volume must be in the same region as your app.
Verify the volume was created:
Step 4: Configure fly.toml
Create the fly.toml configuration file in the root of the cloned repository:
Key configuration details:
shared-cpu-2x: 2 shared vCPUs provide enough burst capacity for OpenClaw's workloads.memory = 2048: 2 GB RAM. TheNODE_OPTIONSflag limits Node.js heap to 1536 MB, leaving room for the OS and other processes.--bind lan: Binds to the private Fly network interface. The Fly proxy handles external traffic routing.force_https = true: All HTTP traffic is redirected to HTTPS. Fly.io provisions and renews TLS certificates automatically.auto_stop_machines = false: Keeps the machine running at all times. Set totrueif you want the machine to stop when idle (saves money but adds cold-start latency).
Step 5: Set Secrets
Fly.io secrets are encrypted environment variables injected at runtime. They never appear in logs or the dashboard:
Generate a strong gateway token:
Step 6: Deploy
Fly.io builds the Docker image remotely, pushes it to its registry, and starts a machine with your configuration. The first deploy takes 2-5 minutes as it builds the image from scratch. Subsequent deploys are faster due to layer caching.
Monitor the deployment:
Wait until the status shows the machine as started and the health checks pass.
Step 7: Configure OpenClaw
Create the OpenClaw configuration file on the persistent volume:
Once inside the container:
Restart the app to pick up the new configuration:
Step 8: Access OpenClaw
Your instance is live at:
Replace openclaw with your app name if you used a different one.
Private Deployment
If you prefer to keep OpenClaw completely off the public internet, remove the allocated IP addresses:
With no public IPs, the app is only accessible through Fly.io's private WireGuard network. Use fly proxy to access it from your local machine:
Then open http://localhost:18789 in your browser. The proxy creates a secure WireGuard tunnel between your machine and the Fly.io private network.
Scaling
Vertical Scaling
To increase the machine size, update fly.toml and redeploy:
Horizontal Scaling
OpenClaw is primarily a single-instance application due to its filesystem-based state. If you need multiple instances for different projects, create separate Fly apps with their own volumes.
Updating OpenClaw
When a new version is released:
Fly.io performs a rolling deployment: it starts a new machine with the updated image, waits for health checks to pass, then stops the old machine. Your volume data at /data is preserved.
Security Best Practices
- Gateway token: Always set a strong
OPENCLAW_GATEWAY_TOKEN. Without it, anyone who discovers your URL can access OpenClaw. - Private deployment: For maximum security, remove public IPs and use
fly proxyas described above. This eliminates all public internet exposure. - Secrets management: Never put API keys in
fly.tomlor the Dockerfile. Always usefly secrets set. - Volume permissions: Data on the Fly volume is encrypted at rest. Fly.io manages the encryption keys.
- Network isolation: Fly.io machines run on dedicated hardware with strong isolation between tenants. Each app gets its own private network namespace.
- Audit access: Use
fly ssh consolesparingly and consider setting up Fly.io organization roles to restrict who can deploy and access the app.
Troubleshooting
Deploy fails with "no machines in group app"
This usually means the volume and machine are in different regions. Verify:
Ensure the volume region matches primary_region in fly.toml.
Health checks failing
Check the logs for startup errors:
Common causes:
- Missing secrets (the app crashes if
ANTHROPIC_API_KEYis not set) - Port mismatch between
fly.tomland the actual process - Volume mount issues (the
/datadirectory is not writable)
Test the health endpoint manually:
Out of memory
If the machine keeps restarting with OOM errors, increase the memory allocation in fly.toml:
Also increase the Node.js heap limit in the env section:
Then redeploy with fly deploy.
Volume is full
Check disk usage:
If the volume is full, extend it:
Cannot connect after removing public IPs
Make sure you are using fly proxy, not trying to access the .fly.dev URL:
If the proxy hangs, ensure WireGuard is configured:
Cost Breakdown
| Resource | Monthly Cost |
|---|---|
| shared-cpu-2x (2 GB RAM) | ~$10.70 |
| 1 GB persistent volume | ~$0.15 |
| Outbound bandwidth (first 100 GB) | Included |
| TLS certificate | Included |
| Total | ~$11 |
With auto_stop_machines = true, costs drop further since you only pay for time the machine is running. However, this adds 3-10 seconds of cold-start latency when the machine spins back up.
Backup
Create a backup of your OpenClaw data:
Schedule periodic backups by combining this with a cron job on your local machine or a CI/CD pipeline.