OpenClaw Gateway Closed (1006 Abnormal Closure) - Fix

Fix the 1006 Abnormal Closure by checking gateway status, port 18789, WebSocket proxy settings, tokens, and logs. For fewer gateway issues, run OpenClaw on Ampere.sh.

What Does OpenClaw Gateway Closed 1006 Mean?

The 1006 Abnormal Closure error is usually a WebSocket connection issue. OpenClaw expected the gateway connection to stay open, but the connection closed without a normal close response.

You may see errors like:

gateway closed (1006 abnormal closure) RPC probe failed: ws://127.0.0.1:18789 gateway closed (1006 abnormal closure) Health check failed: gateway closed (1006 abnormal closure) ECONNREFUSED 127.0.0.1:18789

The error does not always mean OpenClaw itself is broken. It usually means the gateway connection path is broken somewhere - OpenClaw gateway, local machine, browser extension, port 18789, firewall, VPS network rules, reverse proxy, WebSocket config, token/auth settings, or runtime stability.

Quick Fix Summary

Use this table before going deep:

ProblemWhat to Check
Gateway is stoppedStart the OpenClaw gateway
Gateway keeps closingCheck gateway logs
Port issueCheck port 18789
Works locally but not remotelyCheck gateway URL, VPS firewall, and domain
Browser extension shows 1006Check saved gateway URL and token
Domain/proxy setup failsFix WebSocket proxy settings
Token issueMatch gateway auth and remote token
Windows issueCheck OpenClaw Gateway Scheduled Task
Still unstableUse managed OpenClaw hosting

Why This Error Happens

OpenClaw Gateway Closed 1006 usually happens because of one of these causes:

  1. The OpenClaw gateway is not running
  2. The gateway crashed after startup
  3. Port 18789 is already used by another process
  4. The browser or extension is using the wrong gateway URL
  5. 127.0.0.1 is being used incorrectly for a remote VPS
  6. A firewall or VPS security rule is blocking access
  7. Nginx, Caddy, Cloudflare, or another proxy is blocking WebSocket traffic
  8. Gateway token/auth config does not match
  9. Windows Scheduled Task is missing or stopped
  10. The laptop, VPS, or server restarted or went to sleep
  11. OpenClaw is running in a terminal and stops after SSH closes

Step 1: Check OpenClaw Gateway Status

First, check whether the OpenClaw gateway is running.

openclaw gateway status

If the gateway is stopped, start it:

openclaw gateway start

If it is already running but the error still appears, restart it:

openclaw gateway stop openclaw gateway start

Then check recent gateway logs:

openclaw gateway logs --tail 50

If the gateway starts and closes again, the issue is likely a crash, bad config, port conflict, or unstable runtime. For deeper Gateway start issues, see our Gateway won't start guide.

Step 2: Run a Full OpenClaw Health Check

Run a full status check to see whether the issue is really the gateway or something else.

openclaw status --all openclaw gateway status openclaw models status openclaw channels status --probe
CommandWhat It Checks
openclaw status --allFull OpenClaw health
openclaw gateway statusGateway status
openclaw models statusModel and API key setup
openclaw channels status --probeTelegram, WhatsApp, Discord, Slack status

If the gateway works but models fail, fix model/API settings. If the gateway works but channels fail, fix the channel connection. If the gateway itself fails, continue with the next steps.

Step 3: Check Port 18789

OpenClaw gateway commonly uses port 18789.

On macOS or Linux, check the port:

lsof -i :18789

On Windows PowerShell, use:

Get-NetTCPConnection -LocalPort 18789
ResultMeaning
No process foundGateway may not be running
OpenClaw process foundGateway is listening
Another app foundPort conflict
Multiple OpenClaw processes foundDuplicate gateway process

If another process is using the port, stop that process or close the conflicting app. Then restart OpenClaw gateway. To use a different port, see our port change guide.

openclaw gateway stop openclaw gateway start openclaw gateway status

Step 4: Check Localhost vs Remote Gateway URL

This is one of the most common causes of the 1006 abnormal closure error.

If OpenClaw is running on your own laptop, this may work:

ws://127.0.0.1:18789

But if OpenClaw is running on a VPS, your laptop browser cannot use 127.0.0.1:18789 to reach that VPS.

127.0.0.1 means the same machine - not "my server somewhere on the internet."

SetupCorrect Gateway Target
OpenClaw runs on your laptopws://127.0.0.1:18789
OpenClaw runs on VPSVPS IP or domain
OpenClaw runs behind HTTPSwss://your-domain.com
OpenClaw runs behind proxyProxy must support WebSocket

If the browser extension or client is pointing to the wrong gateway URL, update it and reconnect. For extension-specific issues, see our browser extension relay guide.

Important: do not expose your gateway publicly without proper token/auth protection.

Step 5: Check Firewall and VPS Rules

If OpenClaw works locally but fails remotely, the gateway may be blocked by firewall rules.

Check Ubuntu firewall:

sudo ufw status

If you intentionally need to allow gateway access:

sudo ufw allow 18789/tcp

Also check:

  • VPS provider firewall
  • Cloud security group
  • Docker network rules
  • Reverse proxy routing
  • Domain DNS records
  • HTTPS certificate setup

Only open the gateway port if your setup is protected. A public unprotected gateway is not "fast deployment" - it is a security problem waiting to happen. See our VPS install guide for proper setup.

Tired of debugging gateway WebSocket errors?

Ampere.sh runs OpenClaw with managed networking, HTTPS, and WebSocket setup. No port debugging, no proxy headers, no 1006 errors at 2 AM.

Step 6: Fix WebSocket Proxy Issues

If you use Nginx, Caddy, Cloudflare, or another reverse proxy, the 1006 error can happen when the WebSocket upgrade fails.

Common signs:

  • Dashboard loads but gateway disconnects
  • Browser extension shows 1006
  • Gateway works locally but fails on domain
  • It works without proxy but fails with proxy
  • HTTPS page tries to connect to ws:// instead of wss://

For Nginx, make sure WebSocket upgrade headers are passed:

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

Also: use wss:// when the site uses HTTPS, confirm the upstream port is correct, increase proxy timeout if the connection closes quickly, and test direct gateway access before blaming OpenClaw.

Step 7: Check Gateway Token or Auth Mismatch

A token mismatch can cause the connection to open and then close.

Check gateway token config:

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

If they do not match, set the correct token:

openclaw config set gateway.remote.token "your-exact-token-here" openclaw config apply openclaw gateway stop openclaw gateway start

Common token mistakes:

  • Extra space copied into the token
  • Old token saved in the browser extension
  • Token changed but gateway was not restarted
  • Wrong config file or environment variable
  • Stale browser localStorage settings

Step 8: Fix Browser Extension Connection Issues

If the error appears in the OpenClaw browser extension, check the extension connection settings.

  1. Confirm the gateway URL
  2. Confirm the token
  3. Remove old saved connection details
  4. Reconnect the extension
  5. Test another browser profile
  6. Check the browser console for WebSocket errors

If OpenClaw works in terminal but fails in the browser extension, the gateway may not be the real problem. The issue may be the saved gateway URL, stale token, browser storage, or blocked WebSocket connection.

Step 9: Fix Windows Gateway Scheduled Task Issues

On Windows, the OpenClaw gateway may run through a Scheduled Task.

Install the gateway task:

openclaw gateway install

Check the task:

Get-ScheduledTask -TaskName "OpenClaw Gateway"

Start the task:

Start-ScheduledTask -TaskName "OpenClaw Gateway"

Then verify gateway status:

openclaw gateway status

If restart does not work, use stop and start:

openclaw gateway stop openclaw gateway start

If the scheduled task is missing, disabled, or failing, the gateway may not stay online.

Step 10: Check Model and Provider Status

Sometimes users think the gateway is broken, but the real issue is the AI model or API key.

Check model status:

openclaw models status

Test the model:

openclaw models test <model-name>

Common model issues:

  • Missing API key
  • Wrong default model
  • Invalid model name
  • Provider outage
  • Rate limit (see our API rate limit guide)
  • Billing issue
  • Wrong base URL

If the gateway is running but OpenClaw gives no response, check the model/provider before tearing apart your server setup.

Step 11: Check Channel Status

If OpenClaw works in the dashboard but not in Telegram, WhatsApp, Discord, or Slack, check channel status.

openclaw channels status --probe

Then watch logs:

openclaw logs --follow

Send a test message to the channel and check what appears.

What HappensLikely Cause
Nothing appears in logsChannel receiver issue
Message appears but is blockedPairing or allowlist issue
Message appears then model errorModel/API issue
Message appears then gateway closesGateway/runtime issue

This helps you avoid blaming the gateway when the actual problem is channel setup.

Step 12: Check Runtime Stability

If the gateway starts but keeps closing, your runtime may be unstable.

Common causes:

  • VPS memory is too low
  • Server restarted
  • Laptop went to sleep
  • SSH session closed
  • Process is not running as a service
  • Disk is full
  • Logs are too large
  • Runtime crashed
  • Multiple OpenClaw versions conflict

For real workflows, OpenClaw should run as a stable background service or managed deployment. A random terminal tab is not infrastructure. See our 24/7 uptime guide.

Step 13: Read Gateway Logs Properly

Use logs when the quick fixes do not solve the issue.

openclaw gateway logs --tail 100

Watch live logs:

openclaw logs --follow

Optional debug run:

DEBUG=* openclaw gateway start
Log / SymptomLikely Cause
ECONNREFUSEDGateway not running or port blocked
1006 abnormal closureGateway crashed or WebSocket path failed
1008 unauthorizedToken/auth mismatch
port already in usePort conflict
health check failedGateway unreachable
model errorAPI key, model, or provider issue
No logs after messageChannel receiver issue

Logs usually tell you where the failure is. Ignoring logs and guessing is traditional but not effective.

Step 14: Emergency Reset

Use this only after normal fixes fail.

On macOS or Linux:

openclaw gateway stop rm -rf ~/.openclaw/gateway-state/ openclaw gateway start

On Windows PowerShell:

openclaw gateway stop Remove-Item -Recurse -Force $env:USERPROFILE\.openclaw\gateway-state\ openclaw gateway start

Warning: do not delete config, API keys, workspace files, or project data unless you know exactly what you are removing. If you want a safer backup-first approach, see our backup guide.

Best Fix Order

Follow this order to fix OpenClaw Gateway Closed (1006 Abnormal Closure):

  1. Run openclaw gateway status
  2. Start or restart the gateway
  3. Check openclaw gateway logs --tail 50
  4. Check port 18789
  5. Confirm localhost vs remote gateway URL
  6. Check firewall and VPS rules
  7. Fix WebSocket proxy settings
  8. Check gateway token/auth config
  9. Reconnect the browser extension
  10. Check Windows Scheduled Task if using Windows
  11. Check model status
  12. Check channel status
  13. Review full logs
  14. Use emergency reset only if needed

When to Stop Debugging Self-Hosted OpenClaw

Self-hosting is good if you manage:
  • Gateway services
  • Ports
  • Firewalls
  • Reverse proxies
  • WebSocket upgrades
  • Tokens
  • Logs
  • Uptime
  • Background processes
  • Model configuration
Managed hosting is better if you want:
  • To run actual workflows, not babysit gateway connections
  • Stable WebSocket setup out of the box
  • HTTPS handled for you
  • Less time on infrastructure
  • More time on what your agent does

Easiest Fix: Run OpenClaw on Ampere.sh

Ampere.sh helps you run OpenClaw with managed hosting, easier deployment, model setup, uptime handling, and fewer gateway-level problems.

Use Ampere.sh if you want OpenClaw for:

  • AI agents
  • Telegram workflows
  • WhatsApp automation
  • Discord workflows
  • Slack workflows
  • Scheduled tasks
  • Research automation
  • Reminders
  • Browser-based agent work

Instead of debugging ports, proxies, WebSocket upgrades, and background services, you can deploy OpenClaw and focus on the actual workflow.

Quick Commands

CommandPurpose
openclaw status --allCheck full OpenClaw status
openclaw gateway statusCheck gateway status
openclaw gateway startStart gateway
openclaw gateway stopStop gateway
openclaw gateway logs --tail 50View recent gateway logs
openclaw logs --followWatch live logs
openclaw models statusCheck model setup
openclaw models test <model-name>Test selected model
openclaw channels status --probeCheck channel connections
lsof -i :18789Check port on macOS/Linux
Get-NetTCPConnection -LocalPort 18789Check port on Windows
sudo ufw statusCheck Ubuntu firewall
openclaw gateway installInstall Windows gateway task

Frequently Asked Questions

What does OpenClaw Gateway Closed 1006 mean?
It means the OpenClaw gateway WebSocket connection closed unexpectedly without a normal close response.
Is 1006 Abnormal Closure always an OpenClaw bug?
No. It can happen because the gateway stopped, crashed, lost network access, hit a token issue, or failed behind a proxy.
How do I fix OpenClaw Gateway Closed 1006?
Run openclaw gateway status, restart the gateway, check logs, confirm port 18789, verify the gateway URL, and check firewall, proxy, and token settings.
Why does OpenClaw work locally but not remotely?
Usually because 127.0.0.1 only works on the same machine. If OpenClaw runs on a VPS, your browser needs the VPS IP, domain, or a properly configured proxy.
Can Nginx cause OpenClaw Gateway Closed 1006?
Yes. If Nginx does not pass WebSocket upgrade headers correctly, the gateway connection can close with a 1006 error.
Can Cloudflare cause OpenClaw WebSocket problems?
Yes. Cloudflare SSL, proxy, timeout, or WebSocket settings can break the connection if configured incorrectly.
Why does the OpenClaw browser extension show 1006?
The extension may be using the wrong gateway URL, an old token, blocked WebSocket connection, or stale saved settings.
What port does OpenClaw gateway use?
OpenClaw gateway commonly uses port 18789 for the local gateway connection.
Should I use managed hosting for OpenClaw?
Use managed hosting if you want fewer setup problems and do not want to manually manage ports, proxies, gateway services, and uptime.

Also Read

OpenClaw Gateway Won't Start: Every Fix
Guide

OpenClaw Gateway Won't Start: Every Fix

How to Change OpenClaw Default Port: Complete Guide
Guide

How to Change OpenClaw Default Port: Complete Guide

Fix OpenClaw Browser Extension: Relay Not Working
Troubleshooting

Fix OpenClaw Browser Extension: Relay Not Working

Michael Park

Written by

Michael Park

Senior Technical Writer & DevRel

Michael creates comprehensive installation and setup guides for developers and system administrators. With experience across Linux, macOS, Windows, and embedded systems, he has written over 200 technical tutorials used by millions of developers. He focuses on clear, step-by-step instructions that work the first time, covering everything from Raspberry Pi to enterprise servers.

Skip the gateway debugging loop

Managed OpenClaw on Ampere.sh handles ports, proxies, WebSockets, and uptime so you can focus on workflows. 7-day free trial.

Start Free Trial