← Back to Articles
General3 min read

Deploying OpenClaw on Cloudflare Workers

ClawMakers·

Deploying OpenClaw on Cloudflare Workers

You can deploy OpenClaw on Cloudflare Workers to run your gateway in a serverless environment. This setup offers high availability, low latency, and cost efficiency—ideal for lightweight, always-on agent workloads.

Why Cloudflare Workers?

  • Global edge network: Your agent runs close to users worldwide
  • Always-on: No downtime between deploys
  • Free tier: Generous free allowance for prototyping and small-scale use
  • Seamless updates: Zero-downtime deployments
  • Low cold start: Faster initialization than traditional serverless

Prerequisites

  • A Cloudflare account
  • npm and wrangler installed (npm install -g wrangler)
  • OpenClaw CLI installed (npm install -g openclaw)
  • Your OpenClaw configuration file ready

Step 1: Initialize the Worker Project

Create a new directory and initialize a Worker project:

cd ~/projects
mkdir openclaw-worker && cd openclaw-worker
wrangler init

Choose the default JavaScript template.

Step 2: Install OpenClaw

Install OpenClaw as a dependency:

npm install openclaw@latest

Step 3: Write the Worker Script

Replace the default index.js with:

// src/index.js
import { OpenClawWorker } from 'openclaw/worker';

export default {
  async fetch(request, env, ctx) {
    return OpenClawWorker.handle(request, env, ctx, {
      // Optional: override model provider
      // modelProvider: 'anthropic',
      // apiKey: env.ANTHROPIC_API_KEY,
    });
  },
};

Step 4: Configure wrangler.toml

Update wrangler.toml:

name = "openclaw-gateway"
main = "src/index.js"
compatibility_date = "2025-01-01"
keep_vars = ["OPENCLAW_CONFIG"]

[vars]
OPENCLAW_CONFIG = '{"model":"anthropic/claude-3-haiku","channels":{"whatsapp":{"enabled":true}},"gateway":{"port":0}}'

[env.production]
# Use production Anthropic key in prod
# ANTHROPIC_API_KEY = "sk-ant-..."

[triggers]
crons = ["*/30 * * * *"]  # Sync every 30 minutes if needed

Security Note: The full OpenClaw config is embedded in OPENCLAW_CONFIG. For production, consider loading config from KV or process.env securely.

Step 5: Deploy

Deploy to Cloudflare:

wrangler deploy

After deployment, your OpenClaw gateway is live and accepting requests at your Worker URL.

Step 6: Pair Your Client

On your local machine, pair with the remote gateway:

openclaw pair https://openclaw-gateway.<your-subdomain>.workers.dev

Follow the prompts to complete pairing. Your local client will now route all agent activity through the Cloudflare Worker.

Limitations

  • File system access: Not available in Workers environment
  • Browser automation: Requires managed browser, not supported
  • Heavy tool use: CPU-intensive tools may hit Worker limits
  • Local LLMs: Cannot run local models like Ollama

This makes Cloudflare Workers ideal for text-based agent routing and lightweight automation, but not for heavy local tool execution.

Use Cases

✅ Ideal for:

  • Always-on WhatsApp/Telegram gateways
  • Simple workflow routing
  • Global agent presence with low latency

🚫 Not ideal for:

  • Browser automation
  • File system operations
  • Running local LLMs
  • Heavy media processing

Conclusion

Deploying OpenClaw on Cloudflare Workers gives you a resilient, globally distributed gateway with minimal operational overhead. While it doesn't support all local tooling, it's perfect for core messaging and routing use cases.

For full local control, stick with a traditional server or local machine setup. For global reach and uptime, Cloudflare Workers is a strong choice.

Enjoyed this article?

Join the ClawMakers community to discuss this and more with fellow builders.

Join on Skool — It's Free →