ClawKit Logo
ClawKitReliability Toolkit

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.

Related report: openclaw/openclaw#2145.

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.

1006 Recovery Sequence
# 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

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

Check Gateway Process
# 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

Restart Gateway
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

Baseline Network Checks
# 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.

Docker Gateway Debug
# 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-gateway

Add 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 Restart Policy
# 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.

Kill Zombie on Port 18789
# 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 start

Still Getting 1006?

If none of the above matched your situation, use the Doctor tool to diagnose automatically:

Or run the CLI doctor:

Run CLI Doctor
openclaw doctor
openclaw doctor --fix

Did this guide solve your problem?