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:18789The 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:
| Problem | What to Check |
|---|---|
| Gateway is stopped | Start the OpenClaw gateway |
| Gateway keeps closing | Check gateway logs |
| Port issue | Check port 18789 |
| Works locally but not remotely | Check gateway URL, VPS firewall, and domain |
| Browser extension shows 1006 | Check saved gateway URL and token |
| Domain/proxy setup fails | Fix WebSocket proxy settings |
| Token issue | Match gateway auth and remote token |
| Windows issue | Check OpenClaw Gateway Scheduled Task |
| Still unstable | Use managed OpenClaw hosting |
Why This Error Happens
OpenClaw Gateway Closed 1006 usually happens because of one of these causes:
- The OpenClaw gateway is not running
- The gateway crashed after startup
- Port 18789 is already used by another process
- The browser or extension is using the wrong gateway URL
127.0.0.1is being used incorrectly for a remote VPS- A firewall or VPS security rule is blocking access
- Nginx, Caddy, Cloudflare, or another proxy is blocking WebSocket traffic
- Gateway token/auth config does not match
- Windows Scheduled Task is missing or stopped
- The laptop, VPS, or server restarted or went to sleep
- 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 statusIf the gateway is stopped, start it:
openclaw gateway startIf it is already running but the error still appears, restart it:
openclaw gateway stop
openclaw gateway startThen check recent gateway logs:
openclaw gateway logs --tail 50If 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| Command | What It Checks |
|---|---|
openclaw status --all | Full OpenClaw health |
openclaw gateway status | Gateway status |
openclaw models status | Model and API key setup |
openclaw channels status --probe | Telegram, 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 :18789On Windows PowerShell, use:
Get-NetTCPConnection -LocalPort 18789| Result | Meaning |
|---|---|
| No process found | Gateway may not be running |
| OpenClaw process found | Gateway is listening |
| Another app found | Port conflict |
| Multiple OpenClaw processes found | Duplicate 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 statusStep 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:18789But 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."
| Setup | Correct Gateway Target |
|---|---|
| OpenClaw runs on your laptop | ws://127.0.0.1:18789 |
| OpenClaw runs on VPS | VPS IP or domain |
| OpenClaw runs behind HTTPS | wss://your-domain.com |
| OpenClaw runs behind proxy | Proxy 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 statusIf you intentionally need to allow gateway access:
sudo ufw allow 18789/tcpAlso 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 ofwss://
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.tokenIf 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 startCommon 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.
- Confirm the gateway URL
- Confirm the token
- Remove old saved connection details
- Reconnect the extension
- Test another browser profile
- 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 installCheck the task:
Get-ScheduledTask -TaskName "OpenClaw Gateway"Start the task:
Start-ScheduledTask -TaskName "OpenClaw Gateway"Then verify gateway status:
openclaw gateway statusIf restart does not work, use stop and start:
openclaw gateway stop
openclaw gateway startIf 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 statusTest 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 --probeThen watch logs:
openclaw logs --followSend a test message to the channel and check what appears.
| What Happens | Likely Cause |
|---|---|
| Nothing appears in logs | Channel receiver issue |
| Message appears but is blocked | Pairing or allowlist issue |
| Message appears then model error | Model/API issue |
| Message appears then gateway closes | Gateway/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 100Watch live logs:
openclaw logs --followOptional debug run:
DEBUG=* openclaw gateway start| Log / Symptom | Likely Cause |
|---|---|
ECONNREFUSED | Gateway not running or port blocked |
1006 abnormal closure | Gateway crashed or WebSocket path failed |
1008 unauthorized | Token/auth mismatch |
port already in use | Port conflict |
health check failed | Gateway unreachable |
model error | API key, model, or provider issue |
| No logs after message | Channel 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 startOn Windows PowerShell:
openclaw gateway stop
Remove-Item -Recurse -Force $env:USERPROFILE\.openclaw\gateway-state\
openclaw gateway startWarning: 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):
- Run
openclaw gateway status - Start or restart the gateway
- Check
openclaw gateway logs --tail 50 - Check port 18789
- Confirm localhost vs remote gateway URL
- Check firewall and VPS rules
- Fix WebSocket proxy settings
- Check gateway token/auth config
- Reconnect the browser extension
- Check Windows Scheduled Task if using Windows
- Check model status
- Check channel status
- Review full logs
- Use emergency reset only if needed
When to Stop Debugging Self-Hosted OpenClaw
- Gateway services
- Ports
- Firewalls
- Reverse proxies
- WebSocket upgrades
- Tokens
- Logs
- Uptime
- Background processes
- Model configuration
- 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
| Command | Purpose |
|---|---|
openclaw status --all | Check full OpenClaw status |
openclaw gateway status | Check gateway status |
openclaw gateway start | Start gateway |
openclaw gateway stop | Stop gateway |
openclaw gateway logs --tail 50 | View recent gateway logs |
openclaw logs --follow | Watch live logs |
openclaw models status | Check model setup |
openclaw models test <model-name> | Test selected model |
openclaw channels status --probe | Check channel connections |
lsof -i :18789 | Check port on macOS/Linux |
Get-NetTCPConnection -LocalPort 18789 | Check port on Windows |
sudo ufw status | Check Ubuntu firewall |
openclaw gateway install | Install Windows gateway task |
Frequently Asked Questions
What does OpenClaw Gateway Closed 1006 mean?
Is 1006 Abnormal Closure always an OpenClaw bug?
How do I fix OpenClaw Gateway Closed 1006?
Why does OpenClaw work locally but not remotely?
Can Nginx cause OpenClaw Gateway Closed 1006?
Can Cloudflare cause OpenClaw WebSocket problems?
Why does the OpenClaw browser extension show 1006?
What port does OpenClaw gateway use?
Should I use managed hosting for OpenClaw?
Also Read
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

