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):
[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.jsonHealth check failures:
Health check failed: gateway closed (1006 abnormal closure (no close frame)): no close reasonGateway target: ws://127.0.0.1:18789Gateway unreachable:
Gateway: unreachable (connect failed: ECONNREFUSED 127.0.0.1:18789)Gateway service: Scheduled Task not installed1008 Token mismatch:
disconnected (1008): unauthorized: gateway token mismatch (set gateway.remote.token to match gateway.auth.token)CLI argument errors:
error: too many arguments for 'gateway'. Expected 0 arguments but got 1.No response from bot (gateway running but not processing):
# Bot sends scheduled messages but doesn't respond to incoming DMs🔍 Why This Happens
Gateway failures have several root causes:
-
Gateway service not running: The most common cause of 1006 errors — the gateway process simply isn't started or has crashed.
-
Port conflicts: Something else (another OpenClaw instance, another app) is using port 18789.
-
Token mismatch: The
gateway.auth.tokenandgateway.remote.tokenvalues don't match exactly. -
Windows Scheduled Task not installed: On Windows, the gateway runs as a Scheduled Task that may not be installed or may have failed.
-
Webhook/polling conflicts: For Telegram, if a webhook is set on the bot token, long-polling can't receive updates (409 Conflict).
-
Pairing/allowlist blocking messages: Inbound messages may be blocked by access controls even when the gateway is running.
-
Memory/context overflow: Long-running sessions can overflow the context window, causing the agent to fail processing.
-
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:
# Check overall statusopenclaw status --all# Check gateway specificallyopenclaw gateway status# Check if models are configuredopenclaw models status# Check channel connectionsopenclaw channels status --probeWhat 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:
openclaw gateway statusStep 2: Start the gateway:
openclaw gateway startStep 3: If it was running but crashed, check logs:
openclaw gateway logs --tail 50Step 4: Look for port conflicts:
# macOS/Linuxlsof -i :18789# Windows PowerShellGet-NetTCPConnection -LocalPort 18789Fix Windows Gateway Issues
On Windows, the gateway runs as a Scheduled Task that needs to be installed:
Step 1: Install the Windows service:
openclaw gateway installStep 2: Check service status:
Get-ScheduledTask -TaskName "OpenClaw Gateway"Step 3: Start the service:
Start-ScheduledTask -TaskName "OpenClaw Gateway"Step 4: Verify it's running:
openclaw gateway statusCommon Windows issue — CLI syntax:
# 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 startFix 1008 Token Mismatch Errors
The remote token must exactly match the auth token:
Step 1: Check current token configuration:
openclaw config get gateway.auth.tokenopenclaw config get gateway.remote.tokenStep 2: If they don't match, set them to be identical:
openclaw config set gateway.remote.token "your-exact-token-here"Step 3: Apply config and restart:
openclaw config applyopenclaw gateway stopopenclaw gateway startStep 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:
openclaw logs --follow# Now send "ping" to your bot in Telegram/DiscordWhat 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:
# 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>/deleteWebhookStep 3: Check access controls:
# 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 IDTo 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:
Context overflow: prompt too large for the model. Try again with less input or a larger-context model.Solution 1: Reset the session:
# In chat, send:/resetSolution 2: Enable auto-compaction:
Add to your config:
{ "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:
openclaw models statusStep 2: Verify API key is set:
# For Anthropicopenclaw config get models.anthropic.apiKey# For OpenAIopenclaw config get models.openai.apiKeyStep 3: Test the model directly:
openclaw models test anthropic/claude-sonnet-4-20250514Fix DeepSeek and Other Custom Models
DeepSeek isn't in the default model list. Configure it manually:
Step 1: Configure DeepSeek in openclaw.json:
{ "models": { "openai": { "apiKey": "your-deepseek-api-key", "baseUrl": "https://api.deepseek.com" } }, "agent": { "defaultModel": "openai/deepseek-chat" }}Step 2: Apply and restart:
openclaw config applyopenclaw gateway restartFull Gateway Log Analysis
When all else fails, get the full logs:
# Last 100 linesopenclaw gateway logs --tail 100# Follow in real-timeopenclaw logs --follow# With verbose outputDEBUG=* openclaw gateway startEmergency Reset
If the gateway is completely broken:
# Stop everythingopenclaw gateway stop# Clear gateway state (keeps config)rm -rf ~/.openclaw/gateway-state/# Fresh startopenclaw gateway startOn Windows:
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.
🔥 Your AI should run your business, not just answer questions.
We'll show you how.Free to join.
📋 Quick Commands
| Command | Description |
|---|---|
| openclaw status --all | Full status check of gateway, models, and channels |
| openclaw gateway status | Check if gateway is running |
| openclaw gateway start | Start the gateway service |
| openclaw gateway stop | Stop the gateway service |
| openclaw gateway logs --tail 50 | View recent gateway logs |
| openclaw logs --follow | Watch logs in real-time |
| openclaw devices list | List pending device pairing requests |
| openclaw models status | Check model/provider configuration |
| openclaw channels status --probe | Check channel connections |
| lsof -i :18789 | Check what's using the gateway port (macOS/Linux) |
| openclaw gateway install | Install Windows Scheduled Task service |
Related Issues
📚 You Might Also Like
OpenClaw Gateway Token Security: The Master Key You're Probably Mishandling
Your OpenClaw gateway token is the master key to your entire setup. Anyone who has it can access your dashboard, read your conversations, run commands throug...
Telegram
The easiest way to get started. Full bot support with groups, reactions, inline buttons, and rich media. Set up in under 10 minutes.
Cheapest Way to Host OpenClaw 24/7 (Under $5/Month)
Get 24/7 AI assistant hosting for less than a coffee. Compare all options from free to premium.
AI Assistant for Small Business Owners
Stop working IN the business. Start working ON it.
🐙 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 →