Taking OpenClaw from a local development setup to a reliable production deployment involves five concerns: containerization (Docker), process management (pm2 or systemd), reverse proxy with TLS (Caddy or Nginx), health monitoring, and scaling strategy. OpenClaw runs as a single Node.js process, which makes deployment simpler than distributed systems but requires careful attention to persistence, restart policies, and resource limits. This page provides production-ready configurations for each concern, from a minimal Docker Compose setup to a full monitoring stack.
Master deploying openclaw to production
Take the OpenClaw for Production & Advanced Use course with hands-on lessons and challenges.
This production setup runs the Gateway and Caddy reverse proxy as separate containers on an internal network. Only Caddy exposes ports 80/443 to the internet -- the Gateway is not directly accessible. The agents directory is persisted in a Docker volume. Resource limits prevent the Gateway from consuming all host memory. The health check restarts the container after 3 consecutive failures.
Caddy is simpler because it auto-provisions TLS certificates from Let's Encrypt with zero configuration. Nginx is more flexible but requires manual TLS setup with certbot. Both configurations include rate limiting and request size limits. The Nginx config includes WebSocket support headers, which are required if you use the webchat channel.
For bare-metal deployments without Docker, pm2 or systemd keep the Gateway running. pm2 is simpler and includes a monitoring dashboard. Systemd is the standard Linux service manager and integrates with journalctl for log management. Both restart the Gateway automatically after crashes and on system reboots. The systemd unit runs as a dedicated user with elevated file descriptor limits.
The /health endpoint provides comprehensive system status including per-channel and per-agent counts, active sessions, and memory usage. External monitoring services should poll this endpoint every 30 seconds. The stats command provides 24-hour aggregates for capacity planning. Monitor for channel disconnects, which indicate network or token issues with messaging platforms.
The agents directory is the most critical data to back up. It contains SOUL.md personas, MEMORY.md accumulated knowledge, session history, and installed skills -- all irreplaceable. This script backs up everything daily, compresses it, and retains 30 days. Add it to cron with `0 2 * * * /opt/openclaw/backup.sh` to run at 2 AM daily.
Exposing the Gateway port (18789) directly to the internet without a reverse proxy, missing TLS encryption, rate limiting, and request size limits
Always place Caddy, Nginx, or a cloud load balancer in front of the Gateway. The reverse proxy provides TLS, rate limiting, and WebSocket support. The Gateway port should only be accessible on localhost or an internal network.
Not persisting the agents directory, losing all SOUL.md files, MEMORY.md, session history, and installed skills when the container is recreated
Mount the agents directory as a Docker volume or bind mount. This is the most critical data in the entire deployment. Without persistence, every container restart wipes all agent knowledge and configuration.
Running the Gateway without resource limits, allowing a memory leak or runaway process to consume all host resources and crash other services
Set memory and CPU limits in Docker Compose (deploy.resources.limits) or systemd (MemoryLimit, CPUQuota). A 2GB memory limit and 2 CPU cores is sufficient for most deployments.
Setting Docker replicas or Kubernetes replicas to more than 1, expecting horizontal scaling, when the Gateway maintains in-memory session state
OpenClaw is a single-process architecture with in-memory state. Multiple replicas create independent gateways with separate sessions. For high availability, use liveness probes and auto-restart. For throughput, deploy separate gateways per channel.
Not configuring WebSocket support in the reverse proxy, causing the webchat channel to fail with connection timeout errors
Add WebSocket upgrade headers to your Nginx configuration (proxy_http_version 1.1, Upgrade, Connection headers). Caddy handles WebSocket proxying automatically. Test with a WebSocket client before deploying.
Deploying OpenClaw to production requires Docker with a reverse proxy (Caddy or Nginx) for TLS and rate limiting, persistent storage for the agents directory, health checks for automated recovery, resource limits to prevent exhaustion, and external monitoring. Use Docker Compose with Caddy for the simplest production setup. Never expose the Gateway port directly. Persist the agents directory -- it contains irreplaceable data. OpenClaw is single-process; scale by deploying separate gateways per channel, not by adding replicas. Back up daily and test restoration.
Interactive lessons and challenges on Stanza, practice in VS Code, Cursor, or the web.
Interactive lessons and challenges, right in your code editor.
Check the free courses. No credit card.