openclaw - 💡(How to fix) Fix CLI WebSocket handshake timeout - all CLI commands fail to connect gateway [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#48959Fetched 2026-04-08 00:50:31
View on GitHub
Comments
3
Participants
3
Timeline
8
Reactions
0
Author
Participants
Timeline (top)
commented ×3labeled ×2subscribed ×2mentioned ×1

All CLI commands (cron, config, doctor, etc.) fail to connect to the gateway via WebSocket with handshake timeout. The gateway itself runs normally - channel messaging (Feishu) and browser dashboard both work. Only CLI-gateway RPC connections are broken.

Error Message

CLI fails with: Error: gateway closed (1000 normal closure): no close reason

Root Cause

All CLI commands (cron, config, doctor, etc.) fail to connect to the gateway via WebSocket with handshake timeout. The gateway itself runs normally - channel messaging (Feishu) and browser dashboard both work. Only CLI-gateway RPC connections are broken.

RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

All CLI commands (cron, config, doctor, etc.) fail to connect to the gateway via WebSocket with handshake timeout. The gateway itself runs normally - channel messaging (Feishu) and browser dashboard both work. Only CLI-gateway RPC connections are broken.

Steps to reproduce

  1. Install OpenClaw 2026.3.13 via npm global
  2. Start gateway: openclaw gateway start
  3. Run any CLI command: openclaw cron status
  4. Observe: gateway connect failed with handshake timeout

Tested variations that all fail:

  • gateway.auth.mode=none
  • --timeout 30000
  • OPENCLAW_GATEWAY_TOKEN=<token>
  • Fresh gateway restart

Expected behavior

CLI should successfully connect to the gateway via WebSocket (ws://127.0.0.1:18789) and execute commands. Local connections should be automatically approved without requiring device pairing.

Actual behavior

CLI fails with: Error: gateway closed (1000 normal closure): no close reason Gateway logs show: [ws] handshake timeout conn=xxx remote=127.0.0.1

OpenClaw version

2026.3.13 (61d171a)

Operating system

Ubuntu 24.04 (Linux 6.17.0-19-generic x64)

Install method

npm global

Model

deepseek/deepseek-chat

Provider / routing chain

openclaw -> deepseek

Config file / key location

No response

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

Affected: All users who need CLI management (cron, config, doctor) Severity: High (blocks cron management, configuration updates, diagnostics) Frequency: 100% reproducible Consequence: Cannot manage cron jobs via CLI, cannot run diagnostics

Additional information

No response

extent analysis

Fix Plan

To resolve the WebSocket handshake timeout issue, we need to adjust the connection settings and ensure proper authentication.

Step-by-Step Solution:

  1. Increase the handshake timeout: Modify the gateway.config.js file to increase the WebSocket handshake timeout.
// gateway.config.js
module.exports = {
  // ... other configurations ...
  ws: {
    handshakeTimeout: 30000, // 30 seconds
  },
};
  1. Disable authentication for local connections: Update the gateway.auth.js file to bypass authentication for local connections.
// gateway.auth.js
module.exports = {
  // ... other configurations ...
  mode: 'none', // or implement a custom auth mode that allows local connections
};
  1. Verify WebSocket connection: Use a tool like wscat to test the WebSocket connection manually.
wscat -c ws://127.0.0.1:18789

If the connection is successful, you should see a prompt to send messages.

Verification

To verify that the fix worked, run any CLI command, such as openclaw cron status. If the command executes successfully without a handshake timeout error, the issue is resolved.

Extra Tips

  • Ensure that the gateway service is running and listening on the correct port (18789).
  • If issues persist, check the gateway logs for any errors or warnings related to WebSocket connections.
  • Consider implementing a custom authentication mode that allows local connections while maintaining security for remote connections.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

CLI should successfully connect to the gateway via WebSocket (ws://127.0.0.1:18789) and execute commands. Local connections should be automatically approved without requiring device pairing.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING