openclaw - 💡(How to fix) Fix [Bug]: CLI `openclaw cron/gateway` commands fail with "handshake timeout" on v2026.3.13 [4 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#52265Fetched 2026-04-08 01:13:36
View on GitHub
Comments
4
Participants
3
Timeline
8
Reactions
0
Timeline (top)
commented ×4labeled ×2mentioned ×1subscribed ×1
   ## 问题描述                                                                                                                                                      
                                                                                                                                                                    
   `openclaw cron list` / `openclaw gateway status` 等 CLI 命令报错:

Error: gateway closed (1000): Gateway not reachable. Is it running and accessible?
Gateway target: ws://127.0.0.1:18789

                                                                                                                                                                   
  Gateway 本身正常运行(`systemctl --user status openclaw-gateway` 显示 active),TUI 和 Web 也能正常连接,唯独 CLI 命令不行。                                     
                                                                                                                                                                   
  ## 环境                                                                                                                                                          
                                                                                                                                                                   
  - OpenClaw 版本:2026.3.13 (61d171a)                                                                                                                             
  - Node 版本:v22.22.1                                                                                                                                            
  - Gateway 运行方式:systemd service (loopback only, port 18789)                                                                                                  
  - OS:Linux 5.14.0 (x64)                                                                                                                                         
                                                                                                                                                                   
  ## 日志                                                                                                                                                          
                                                                                                                                                                   
  Gateway 日志 (`/tmp/openclaw/openclaw-*.log`) 中出现:

handshake timeout conn=... remote=127.0.0.1
handshake failed, cause: handshake-timeout, handshakeMs: 3002
closed before connect ... code=1000 reason=n/a

                                                                                                                                                                   
  WebSocket 直连测试正常(`curl` 发送 `connect.challenge` 请求能收到响应),说明 Gateway 端没问题。                                                                
                                                                                                                                                                   
  ## 验证                                                                                                                                                          
                                                                                                                                                                   
  - `curl --noproxy '*' -H "Upgrade: websocket" ... http://127.0.0.1:18789/` ✅ 正常                                                                               
  - TUI 连接 Gateway ✅ 正常                                                                                                                                       
  - Web 连接 Gateway ✅ 正常                                                                                                                                       
  - `openclaw cron list` ❌ handshake timeout                                                                                                                      
                                                                                                                                                                   
  ## 附加信息                                                                                                                                                      
                                                                                                                                                                   
  - CLI 的 `DEFAULT_HANDSHAKE_TIMEOUT_MS = 3000`(3秒),CLI 似乎没有正确处理 `connect.challenge` 响应就关闭了连接

Error Message

Error: gateway closed (1000): Gateway not reachable. Is it running and accessible? 5. 观察输出:gateway connect failed: Error: gateway closed (1000) gateway connect failed: Error: gateway closed (1000): Error: gateway closed (1000 normal closure): no close reason

Root Cause

   ## 问题描述                                                                                                                                                      
                                                                                                                                                                    
   `openclaw cron list` / `openclaw gateway status` 等 CLI 命令报错:

Error: gateway closed (1000): Gateway not reachable. Is it running and accessible?
Gateway target: ws://127.0.0.1:18789

                                                                                                                                                                   
  Gateway 本身正常运行(`systemctl --user status openclaw-gateway` 显示 active),TUI 和 Web 也能正常连接,唯独 CLI 命令不行。                                     
                                                                                                                                                                   
  ## 环境                                                                                                                                                          
                                                                                                                                                                   
  - OpenClaw 版本:2026.3.13 (61d171a)                                                                                                                             
  - Node 版本:v22.22.1                                                                                                                                            
  - Gateway 运行方式:systemd service (loopback only, port 18789)                                                                                                  
  - OS:Linux 5.14.0 (x64)                                                                                                                                         
                                                                                                                                                                   
  ## 日志                                                                                                                                                          
                                                                                                                                                                   
  Gateway 日志 (`/tmp/openclaw/openclaw-*.log`) 中出现:

handshake timeout conn=... remote=127.0.0.1
handshake failed, cause: handshake-timeout, handshakeMs: 3002
closed before connect ... code=1000 reason=n/a

                                                                                                                                                                   
  WebSocket 直连测试正常(`curl` 发送 `connect.challenge` 请求能收到响应),说明 Gateway 端没问题。                                                                
                                                                                                                                                                   
  ## 验证                                                                                                                                                          
                                                                                                                                                                   
  - `curl --noproxy '*' -H "Upgrade: websocket" ... http://127.0.0.1:18789/` ✅ 正常                                                                               
  - TUI 连接 Gateway ✅ 正常                                                                                                                                       
  - Web 连接 Gateway ✅ 正常                                                                                                                                       
  - `openclaw cron list` ❌ handshake timeout                                                                                                                      
                                                                                                                                                                   
  ## 附加信息                                                                                                                                                      
                                                                                                                                                                   
  - CLI 的 `DEFAULT_HANDSHAKE_TIMEOUT_MS = 3000`(3秒),CLI 似乎没有正确处理 `connect.challenge` 响应就关闭了连接

Code Example

## 问题描述                                                                                                                                                      
                                                                                                                                                                    
   `openclaw cron list` / `openclaw gateway status`CLI 命令报错:

---

Gateway 本身正常运行(`systemctl --user status openclaw-gateway` 显示 active),TUIWeb 也能正常连接,唯独 CLI 命令不行。                                     
                                                                                                                                                                    
   ## 环境                                                                                                                                                          
                                                                                                                                                                    
   - OpenClaw 版本:2026.3.13 (61d171a)                                                                                                                             
   - Node 版本:v22.22.1                                                                                                                                            
   - Gateway 运行方式:systemd service (loopback only, port 18789)                                                                                                  
   - OS:Linux 5.14.0 (x64)                                                                                                                                         
                                                                                                                                                                    
   ## 日志                                                                                                                                                          
                                                                                                                                                                    
   Gateway 日志 (`/tmp/openclaw/openclaw-*.log`) 中出现:

---

WebSocket 直连测试正常(`curl` 发送 `connect.challenge` 请求能收到响应),说明 Gateway 端没问题。                                                                
                                                                                                                                                                    
   ## 验证                                                                                                                                                          
                                                                                                                                                                    
   - `curl --noproxy '*' -H "Upgrade: websocket" ... http://127.0.0.1:18789/` ✅ 正常                                                                               
   - TUI 连接 Gateway ✅ 正常                                                                                                                                       
   - Web 连接 Gateway ✅ 正常                                                                                                                                       
   - `openclaw cron list` ❌ handshake timeout                                                                                                                      
                                                                                                                                                                    
   ## 附加信息                                                                                                                                                      
                                                                                                                                                                    
   - CLI`DEFAULT_HANDSHAKE_TIMEOUT_MS = 3000`3秒),CLI 似乎没有正确处理 `connect.challenge` 响应就关闭了连接

---
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Summary

   ## 问题描述                                                                                                                                                      
                                                                                                                                                                    
   `openclaw cron list` / `openclaw gateway status` 等 CLI 命令报错:

Error: gateway closed (1000): Gateway not reachable. Is it running and accessible?
Gateway target: ws://127.0.0.1:18789

                                                                                                                                                                   
  Gateway 本身正常运行(`systemctl --user status openclaw-gateway` 显示 active),TUI 和 Web 也能正常连接,唯独 CLI 命令不行。                                     
                                                                                                                                                                   
  ## 环境                                                                                                                                                          
                                                                                                                                                                   
  - OpenClaw 版本:2026.3.13 (61d171a)                                                                                                                             
  - Node 版本:v22.22.1                                                                                                                                            
  - Gateway 运行方式:systemd service (loopback only, port 18789)                                                                                                  
  - OS:Linux 5.14.0 (x64)                                                                                                                                         
                                                                                                                                                                   
  ## 日志                                                                                                                                                          
                                                                                                                                                                   
  Gateway 日志 (`/tmp/openclaw/openclaw-*.log`) 中出现:

handshake timeout conn=... remote=127.0.0.1
handshake failed, cause: handshake-timeout, handshakeMs: 3002
closed before connect ... code=1000 reason=n/a

                                                                                                                                                                   
  WebSocket 直连测试正常(`curl` 发送 `connect.challenge` 请求能收到响应),说明 Gateway 端没问题。                                                                
                                                                                                                                                                   
  ## 验证                                                                                                                                                          
                                                                                                                                                                   
  - `curl --noproxy '*' -H "Upgrade: websocket" ... http://127.0.0.1:18789/` ✅ 正常                                                                               
  - TUI 连接 Gateway ✅ 正常                                                                                                                                       
  - Web 连接 Gateway ✅ 正常                                                                                                                                       
  - `openclaw cron list` ❌ handshake timeout                                                                                                                      
                                                                                                                                                                   
  ## 附加信息                                                                                                                                                      
                                                                                                                                                                   
  - CLI 的 `DEFAULT_HANDSHAKE_TIMEOUT_MS = 3000`(3秒),CLI 似乎没有正确处理 `connect.challenge` 响应就关闭了连接

Steps to reproduce

  1. 启动 OpenClaw Gateway(systemctl --user start openclaw-gateway
  2. 确认 Gateway 正常运行:systemctl --user status openclaw-gateway 显示 active (running)
  3. 确认 TUI/Web 能正常连接 Gateway
  4. 在终端执行:unset http_proxy https_proxy && openclaw cron list
  5. 观察输出:gateway connect failed: Error: gateway closed (1000)

Expected behavior

openclaw cron list 正常输出 cron 任务列表,或至少能连接到 Gateway。

Actual behavior

gateway connect failed: Error: gateway closed (1000):
Error: gateway closed (1000 normal closure): no close reason
Gateway target: ws://127.0.0.1:18789
Source: local loopback
Config: /home/chyd/.openclaw/openclaw.json
Bind: loopback

OpenClaw version

OpenClaw 2026.3.13 (61d171a)

Operating system

Almalinux 9.7

Install method

npm install -g openclaw@latest

Model

minimax-portal/MiniMax-M2.7

Provider / routing chain

openclaw->minmax

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

To resolve the gateway closed (1000) error when running openclaw cron list or openclaw gateway status commands, we need to adjust the handshake timeout in the CLI.

Here are the steps:

  • Increase the DEFAULT_HANDSHAKE_TIMEOUT_MS value in the CLI code to a higher value than the current 3000ms to allow for more time to establish a connection.
  • Ensure that the connect.challenge response is properly handled by the CLI to prevent premature connection closure.

Example code adjustment:

// Increase the handshake timeout to 10 seconds
const DEFAULT_HANDSHAKE_TIMEOUT_MS = 10000;

// Properly handle connect.challenge response
// Assuming 'ws' is the WebSocket object
ws.on('message', (data) => {
  if (data === 'connect.challenge') {
    // Handle the challenge response
    // ...
  }
});

Verification

To verify that the fix worked:

  1. Run openclaw cron list or openclaw gateway status after applying the code changes.
  2. Check if the command executes without the gateway closed (1000) error.
  3. Confirm that the Gateway is reachable and responsive.

Extra Tips

  • Ensure that the system's proxy settings are not interfering with the WebSocket connection.
  • Verify that the Gateway is running and accessible on the specified port (18789 in this case).
  • If issues persist, check the Gateway logs for any errors or warnings related to the handshake process.

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

openclaw cron list 正常输出 cron 任务列表,或至少能连接到 Gateway。

Still need to ship something?

×6

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

Back to top recommendations

TRENDING