🦞OpenClaw Guide
Gateway

OpenClaw Gateway Crashes or Won't Start — Complete Fix Guide

Comprehensive troubleshooting for gateway startup failures, 1006/1008 WebSocket errors, token mismatches, health check failures, and platform-specific issues on Windows, macOS, and Linux.

⚠️ The Problem

The OpenClaw gateway fails to start, crashes, or shows connection errors:

1006 WebSocket closure (most common):

bash
[openclaw] Failed to start CLI: Error: gateway closed (1006 abnormal closure (no close frame)): no close reasonGateway target: ws://127.0.0.1:18789Source: local loopbackConfig: C:\Users\Leran\.openclaw\openclaw.json

Health check failures:

bash
Health check failed: gateway closed (1006 abnormal closure (no close frame)): no close reasonGateway target: ws://127.0.0.1:18789

Gateway unreachable:

bash
Gateway: unreachable (connect failed: ECONNREFUSED 127.0.0.1:18789)Gateway service: Scheduled Task not installed

1008 Token mismatch:

bash
disconnected (1008): unauthorized: gateway token mismatch (set gateway.remote.token to match gateway.auth.token)

CLI argument errors:

bash
error: too many arguments for 'gateway'. Expected 0 arguments but got 1.

No response from bot (gateway running but not processing):

bash
# Bot sends scheduled messages but doesn't respond to incoming DMs

🔍 Why This Happens

Gateway failures have several root causes:

  1. Gateway service not running: The most common cause of 1006 errors — the gateway process simply isn't started or has crashed.

  2. Port conflicts: Something else (another OpenClaw instance, another app) is using port 18789.

  3. Token mismatch: The gateway.auth.token and gateway.remote.token values don't match exactly.

  4. Windows Scheduled Task not installed: On Windows, the gateway runs as a Scheduled Task that may not be installed or may have failed.

  5. Webhook/polling conflicts: For Telegram, if a webhook is set on the bot token, long-polling can't receive updates (409 Conflict).

  6. Pairing/allowlist blocking messages: Inbound messages may be blocked by access controls even when the gateway is running.

  7. Memory/context overflow: Long-running sessions can overflow the context window, causing the agent to fail processing.

  8. Model/provider errors: The gateway is running but the model provider (OpenAI, Anthropic, etc.) is failing.

The Fix

Quick Diagnosis

Run these commands first to understand the problem:

bash
# Check overall statusopenclaw status --all# Check gateway specificallyopenclaw gateway status# Check if models are configuredopenclaw models status# Check channel connectionsopenclaw channels status --probe

What to look for:

  • Gateway: unreachable → Gateway not running
  • Gateway service: Scheduled Task not installed → Windows service issue
  • Models: no default model → API key issue
  • Channels: disconnected → Channel-specific issue

Fix Gateway Not Running (1006 Errors)

The 1006 error means the WebSocket closed unexpectedly — usually because the gateway isn't running.

Step 1: Check if gateway is running:

bash
openclaw gateway status

Step 2: Start the gateway:

bash
openclaw gateway start

Step 3: If it was running but crashed, check logs:

bash
openclaw gateway logs --tail 50

Step 4: Look for port conflicts:

bash
# macOS/Linuxlsof -i :18789# Windows PowerShellGet-NetTCPConnection -LocalPort 18789

Fix Windows Gateway Issues

On Windows, the gateway runs as a Scheduled Task that needs to be installed:

Step 1: Install the Windows service:

powershell
openclaw gateway install

Step 2: Check service status:

powershell
Get-ScheduledTask -TaskName "OpenClaw Gateway"

Step 3: Start the service:

powershell
Start-ScheduledTask -TaskName "OpenClaw Gateway"

Step 4: Verify it's running:

powershell
openclaw gateway status

Common Windows issue — CLI syntax:

powershell
# This is WRONG on some versions:openclaw gateway restart# error: too many arguments for 'gateway'# Try this instead:openclaw gateway call gateway.restart# Or stop and start:openclaw gateway stopopenclaw gateway start

Fix 1008 Token Mismatch Errors

The remote token must exactly match the auth token:

Step 1: Check current token configuration:

bash
openclaw config get gateway.auth.tokenopenclaw config get gateway.remote.token

Step 2: If they don't match, set them to be identical:

bash
openclaw config set gateway.remote.token "your-exact-token-here"

Step 3: Apply config and restart:

bash
openclaw config applyopenclaw gateway stopopenclaw gateway start

Step 4: Also check browser localStorage:

Open DevTools (F12) → Application → Local Storage → look for openclaw.control.settings.v1. The token there must match your config.

Fix "No Response" Issues (Gateway Running but Bot Silent)

If the bot sends scheduled messages but doesn't respond to DMs, the gateway is running but not processing inbound messages.

Step 1: Watch logs in real-time and send a test message:

bash
openclaw logs --follow# Now send "ping" to your bot in Telegram/Discord

What to look for:

  • Nothing logged when you DM → Receiver is dead/misconfigured (webhook or polling issue)
  • Message logged but "blocked/unauthorized/pairing" → Access control issue
  • Message logged but model errors → Provider/API key issue

Step 2: Fix Telegram webhook conflicts:

bash
# Check if a webhook is setcurl https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getWebhookInfo# If webhook_url is set, delete it for long-polling:curl https://api.telegram.org/bot<YOUR_BOT_TOKEN>/deleteWebhook

Step 3: Check access controls:

bash
# Check if you need to approve pairingopenclaw devices list# Approve if pendingopenclaw devices approve <CODE># Check allowlist (for Telegram)openclaw config get channels.telegram.allowFrom# This should contain your numeric Telegram user ID

To get your Telegram user ID:

Message @userinfobot on Telegram — it will tell you your numeric ID.

Fix Context Overflow / Memory Issues

Long-running sessions can hit context limits:

bash
Context overflow: prompt too large for the model. Try again with less input or a larger-context model.

Solution 1: Reset the session:

bash
# In chat, send:/reset

Solution 2: Enable auto-compaction:

Add to your config:

json
{  "agent": {    "compaction": {      "enabled": true,      "threshold": 50000    }  }}

Solution 3: Use a larger context model:

Claude 3.5 Sonnet has 200k context, GPT-4-turbo has 128k. Switch if you're hitting limits.

Fix Model/Provider Errors

If the gateway runs but the model fails:

Step 1: Check model status:

bash
openclaw models status

Step 2: Verify API key is set:

bash
# For Anthropicopenclaw config get models.anthropic.apiKey# For OpenAIopenclaw config get models.openai.apiKey

Step 3: Test the model directly:

bash
openclaw models test anthropic/claude-sonnet-4-20250514

Fix DeepSeek and Other Custom Models

DeepSeek isn't in the default model list. Configure it manually:

Step 1: Configure DeepSeek in openclaw.json:

json
{  "models": {    "openai": {      "apiKey": "your-deepseek-api-key",      "baseUrl": "https://api.deepseek.com"    }  },  "agent": {    "defaultModel": "openai/deepseek-chat"  }}

Step 2: Apply and restart:

bash
openclaw config applyopenclaw gateway restart

Full Gateway Log Analysis

When all else fails, get the full logs:

bash
# Last 100 linesopenclaw gateway logs --tail 100# Follow in real-timeopenclaw logs --follow# With verbose outputDEBUG=* openclaw gateway start

Emergency Reset

If the gateway is completely broken:

bash
# Stop everythingopenclaw gateway stop# Clear gateway state (keeps config)rm -rf ~/.openclaw/gateway-state/# Fresh startopenclaw gateway start

On Windows:

powershell
openclaw gateway stopRemove-Item -Recurse -Force $env:USERPROFILE\.openclaw\gateway-state\openclaw gateway start

🚀 Skip the setup. OpenClaw Cloud is ready in 60 seconds.

No server. No SSH. No config files. Just connect your channel and go.

Deploy Now — 50% Off First Month →

🔥 Your AI should run your business, not just answer questions.

We'll show you how.Free to join.

Join Vibe Combinator →

📋 Quick Commands

CommandDescription
openclaw status --allFull status check of gateway, models, and channels
openclaw gateway statusCheck if gateway is running
openclaw gateway startStart the gateway service
openclaw gateway stopStop the gateway service
openclaw gateway logs --tail 50View recent gateway logs
openclaw logs --followWatch logs in real-time
openclaw devices listList pending device pairing requests
openclaw models statusCheck model/provider configuration
openclaw channels status --probeCheck channel connections
lsof -i :18789Check what's using the gateway port (macOS/Linux)
openclaw gateway installInstall Windows Scheduled Task service

Related Issues

🐙 Your AI should run your business.

Weekly live builds + template vault. We'll show you how to make AI actually work.Free to join.

Join Vibe Combinator →