Sonu Sahani logo
Sonusahani.com
How to Fix OpenClaw disconnected (1006): no reason?

How to Fix OpenClaw disconnected (1006): no reason?

0 views
5 min read
#OpenClaw

If you are seeing this error:

Error: gateway closed (1006 abnormal closure (no close frame)): no close reason Gateway target: ws://127.0.0.1:18789

or disconnected (1006): no reason

OpenClaw disconnected (1006): no reason

you are not alone. This issue appears in the Web UI, CLI, and dashboard for both OpenClaw and Clawdbot. In most cases, the gateway starts, then closes after a few seconds. Sometimes it disconnects immediately after sending a prompt.

This guide summarizes what actually worked for people and how you can fix it step by step.

What Error 1006 Means

WebSocket error 1006 means the connection was closed abnormally. There is no proper close frame and no clear reason provided by the server. In OpenClaw, this usually points to:

  • Gateway not reachable on 127.0.0.1:18789
  • WebSocket upgrade failing
  • Firewall blocking traffic
  • Reverse proxy misconfiguration
  • VPN / TUN networking issues
  • Channel integration problems (Telegram, etc.)
  • Docker container not running correctly

The fix depends on your environment.

1. If You Are Using Nginx (VPS / Reverse Proxy)

If you are running OpenClaw behind Nginx, this is one of the most common causes. WebSockets require special headers. Without them, the gateway disconnects with 1006. Make sure your Nginx config includes WebSocket upgrade headers:

location / {
    proxy_pass http://127.0.0.1:18789;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    proxy_read_timeout 3600;
    proxy_send_timeout 3600;
}

After updating:

sudo systemctl restart nginx

Then reload OpenClaw. This alone fixed the issue for several VPS users.

2. If You Are Using Tailscale or HTTPS Proxy

Some users resolved this by letting Tailscale handle HTTPS termination:

  • Serve HTTPS on port 443 using Tailscale
  • Let Tailscale manage TLS certificates
  • Proxy traffic to http://localhost:18789

This prevents WebSocket upgrade failures caused by TLS misconfiguration.

3. If You Are on Debian / Ubuntu (Firewall Issue)

Sometimes the gateway is running, but firewall rules block traffic. Allow both TCP and UDP on the Web UI port:

sudo iptables -A INPUT -p tcp --dport 18789 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 18789 -j ACCEPT

Then force restart the gateway:

clawdbot gateway --force

Important: iptables rules are not persistent after reboot unless saved.

4. If You Are Using Docker

Check if the container is running:

sudo docker ps

If you see OpenClaw or gateway in the list, restart it:

sudo docker restart CONTAINER_NAME

Then refresh the Web UI and wait a few seconds after login. A stale container often causes repeated 1006 closures.

5. If Telegram Channel Was Configured

Multiple users reported that the issue started immediately after configuring Telegram. Fix:

clawdbot configure

Then:

  1. Open Channels
  2. Disable Telegram (or disable all channels temporarily)

After disabling Telegram, the gateway remained stable. Some suspect unstable network routing to Telegram causes the disconnect.

6. VPN Users: Enable TUN Mode

If you are running behind a VPN, this may be the root cause. Enabling TUN mode in your VPN resolved the issue for several users. If you are using a VPN client:

  • Enable TUN interface
  • Restart OpenClaw
  • Retry connection

This is especially relevant for users in restricted network environments.

7. Try Device Approval (If CLI Fails)

Some users tried:

clawdbot devices list
clawdbot devices approve {id}

This works only if device authorization is the issue. If it does not fix it, the problem is likely network or gateway related.

8. Full Reinstallation (If Configuration Is Corrupted)

If nothing works, try a clean reinstall:

  1. Remove entire OpenClaw/Clawdbot installation
  2. Reinstall from scratch
  3. Choose local configuration
  4. Skip chat channel setup initially
  5. Complete onboarding

Add models manually:

clawdbot config model

When entering API keys, paste them directly instead of referencing environment variables. Then restart the gateway multiple times to confirm stability. Corrupted configuration files have caused persistent 1006 errors in some cases.

9. If It Disconnects Only After Sending a Prompt

If the gateway stays connected but disconnects after prompting:

  • Try shorter prompts
  • Check for rate limiting
  • Check network stability
  • Verify model configuration
  • Restart the gateway

This can happen if the backend crashes when processing the request.

10. macOS / Windows Users

If setup completes successfully but both Web UI and CLI fail with: Error: gateway closed (1006 abnormal closure (no close frame)): no close reason

Focus on:

  • Firewall rules
  • VPN interference
  • Proxy configuration
  • Port conflicts on 18789

On Windows, also verify no other service is using that port:

netstat -ano | findstr 18789

Why This Happens

Error 1006 does not give a detailed reason because the WebSocket closes without a proper shutdown message. In most cases, the root cause is network routing, proxy headers, firewall blocking, or unstable channel integrations. Once the gateway can maintain a stable WebSocket session, the problem disappears.

Subscribe to our newsletter

Get the latest updates and articles directly in your inbox.

sonuai.dev

Sonu Sahani

AI Engineer & Full Stack Developer. Passionate about building AI-powered solutions.

Related Posts