troubleshooting openclaw whatsapp websocket disconnected 1006

Fix: WhatsApp Disconnected (1006) in OpenClaw

Getting 'disconnected (1006): no reason' in OpenClaw? Your WhatsApp WebSocket dropped. Here's how to reconnect and stop it from happening again.

Fix: WhatsApp Disconnected (1006) in OpenClaw

TL;DR: The WhatsApp WebSocket connection dropped. Re-pair your device and check your network.

The Error

disconnected (1006): no reason

You might also see:

WhatsApp connection closed unexpectedly (code: 1006)
channel whatsapp: disconnected — retrying in 30s
Error: WebSocket connection to WhatsApp servers failed (1006)

Why This Happens

WhatsApp Web connections use WebSockets — a persistent, always-on connection between your server and WhatsApp's servers. Error code 1006 means the connection was closed abnormally (no clean goodbye from either side).

Common causes:

  • Network instability — Your server's internet connection dropped briefly, or there's a flaky route to WhatsApp's servers
  • WhatsApp session expired — WhatsApp periodically invalidates linked device sessions, especially if the primary phone was offline
  • Server went to sleep — If you're running on a laptop or a VPS with aggressive power management
  • WhatsApp rate limiting — Too many messages in a short period can trigger a temporary disconnect
  • Primary phone offline too long — WhatsApp requires your phone to connect to the internet at least once every ~14 days

(GitHub #2145)

How to Fix It

Step 1: Check if it auto-reconnected

Sometimes the connection drops and recovers on its own. Check:

openclaw channel whatsapp status

If it shows connected, you're fine. The disconnect was temporary.

Step 2: Re-pair your WhatsApp device

If the connection didn't recover, you need to re-link:

openclaw channel whatsapp pair

This will show a QR code in your terminal. On your phone:

  1. Open WhatsApp → Settings → Linked Devices
  2. Tap Link a Device
  3. Scan the QR code

If you can't see the QR code (e.g., running headless over SSH):

openclaw channel whatsapp pair --text

This gives you a pairing code you can type in manually instead of scanning.

Step 3: Verify the connection

openclaw channel whatsapp status
openclaw health

Send yourself a test message to confirm it's working.

Step 4: Check your network (if it keeps happening)

# Test connectivity to WhSocket servers
curl -s -o /dev/null -w "%{http_code}" https://web.whatsapp.com

# Check for packet loss
ping -c 20 web.whatsapp.com

# Check your server's uptime
uptime

If you're seeing packet loss or high latency, the problem is your network, not OpenClaw.

How to Prevent It

Enable auto-reconnect

Make sure auto-reconnect is enabled in your config:

{
  "channels": {
    "whatsapp": {
      "autoReconnect": true,
      "reconnectDelay": 5000,
      "maxReconnectAttempts": 50
    }
  }
}

Keep your primary phone online

WhatsApp will invalidate linked device sessions if your primary phone hasn't been online in ~14 days. If your phone is frequently offline (airplane mode, dead battery), expect more disconnects.

Use a stable network

If you're running OpenClaw on a home server with consumer internet, consider:

  • Using a wired connection (not Wi-Fi)
  • Setting up a watchdog that restarts the WhatsApp channel on disconnect
  • Running on a VPS with better uptime guarantees

Monitor the connection

Add a simple watchdog script:

#!/bin/bash
# Save as ~/check-whatsapp.sh and add to crontab
status=$(openclaw channel whatsapp status 2>&1)
if echo "$status" | grep -q "disconnected"; then
  openclaw channel whatsapp reconnect
  echo "$(date): WhatsApp reconnected" >> ~/whatsapp-watchdog.log
fi
# Run every 5 minutes
crontab -e
# Add: */5 * * * * ~/check-whatsapp.sh

The Easy Way

lobsterfarm is a managed hosting service for OpenClaw — deployment, updates, and support handled for you.

Get started with lobsterfarm →

Skip the setup. Start using your AI assistant today.

lobsterfarm gives you a fully managed OpenClaw instance — one click, your own server, running 24/7.