Gateway Closed (1006) Playbook
What 1006 Means
WebSocket close code 1006 means the connection was terminated abnormally — no close frame was sent. The Gateway process crashed, was killed, or lost network access without a clean shutdown.
Unlike 1008 (authentication failure), 1006 is always a connection-level problem. The Gateway either stopped running or became unreachable before it could close the connection cleanly.
Next Step
Fix now, then reduce repeat incidents
If this issue keeps coming back, validate your setup in Doctor first, then harden your config.
1-Minute Recovery Sequence
Run these in order. Most 1006 errors are fixed by step 3.
# 1. Check if Gateway process is running # macOS/Linux: ps aux | grep openclaw # Windows: tasklist | findstr openclaw # 2. Check if port 18789 is occupied # macOS/Linux: lsof -i :18789 # Windows: netstat -ano | findstr :18789 # 3. Restart the Gateway openclaw gateway restart # 4. Check Gateway health openclaw gateway status
Jump to Root Cause
Root Cause 1: Gateway Process Crashed
This is the most common 1006 cause. The Gateway node process exited (OOM, uncaught exception, OS signal) and left the WebSocket connection dangling.
How to Confirm
# macOS / Linux — no output means Gateway is not running ps aux | grep "openclaw gateway" | grep -v grep # Windows tasklist | findstr "openclaw" # Check Gateway logs for crash reason openclaw logs --follow
Fix
openclaw gateway restart # If restart fails, stop completely first openclaw gateway stop # Wait 3 seconds, then: openclaw gateway start
If the Gateway keeps crashing and returning to 1006, stream logs with openclaw logs --follow. Look for the line before the crash — that's the actual error. Common causes: out-of-memory, config parse error, or port conflict.
Root Cause 2: Network Drop or Firewall
If the Gateway process is running but you still get 1006, a firewall or network interruption closed the WebSocket mid-session. This is common in:
VPN reconnections
VPN drop/reconnect kills existing TCP connections. The Gateway is still running, but your WebSocket session was terminated.
Corporate firewalls
Idle WebSocket connections are often killed after 30–120 seconds by stateful firewalls. Enable ping/pong keepalive in your config.
Router NAT timeout
Home routers may close long-lived connections. Same fix: keepalive.
Stabilize Network Path
# Verify gateway reachable openclaw gateway status # Stream logs during reconnect attempts openclaw logs --follow # If behind VPN/proxy/firewall, reconnect network and retry openclaw gateway restart
Root Cause 3: Docker Container Exited
If you run the Gateway in Docker, a 1006 error often means the container stopped. Docker containers exit silently on OOM, healthcheck failure, or resource limit.
# Check container status
docker ps -a | grep openclaw
# View exit reason
docker logs openclaw-gateway --tail 50
# Restart if stopped
docker compose up -d openclaw-gateway
# Check health
docker inspect --format='{{.State.Health.Status}}' openclaw-gatewayAdd restart: unless-stopped
Add restart: unless-stopped to your gateway service in docker-compose.yml so it automatically recovers from crashes. Without it, any container exit causes persistent 1006 until you manually restart.
# docker-compose.yml
services:
openclaw-gateway:
image: openclaw/gateway:latest
restart: unless-stopped
ports:
- "18789:18789"Root Cause 4: Zombie Process Conflict
A previous Gateway crash may have left a zombie process on port 18789. Your new Gateway starts but can't bind the port, and immediately exits — causing 1006.
# macOS / Linux
lsof -ti :18789 | xargs kill -9
# Windows
for /f "tokens=5" %a in ('netstat -ano ^| findstr :18789') do taskkill /PID %a /F
# Verify port is free, then restart
openclaw gateway startStill Getting 1006?
If none of the above matched your situation, use the Doctor tool to diagnose automatically:
Or run the CLI doctor:
openclaw doctor openclaw doctor --fix
Related Fixes
Other connection errors you may see alongside 1006:
Other Tools
Config Wizard
Generate a production-ready clawhub.json in 30 seconds.
Local Doctor
Diagnose Node.js, permissions, and config issues instantly.
Cost Simulator
Calculate your agent burn rate before you get surprised.
Gateway Monitor
Detect token spikes and gateway incidents before users complain.
Skill Finder
Describe your use case and find the right Claude Code skill instantly.
Did this guide solve your problem?