Skip to content

[Bug]: WSL local gateway binds but WebSocket handshake times out on 2026.4.26 #73592

Closed

Description

@Vksh07

Bug type

Regression / local gateway connectivity

Summary

On WSL2, OpenClaw 2026.4.26 starts the local gateway service and binds 127.0.0.1:18789, but local clients fail to complete the WebSocket pre-auth/connect handshake. The gateway port is listening, and the service reports active (running), but CLI/dashboard/WebSocket clients time out or close before connect.

This appears related to the current gateway WebSocket handshake path rather than a missing binary, invalid config, or WSL being down.

Environment

  • OpenClaw: 2026.4.26 (be8c246)
  • OS: WSL2 Ubuntu 24.04.4 LTS on Windows
  • Kernel: 6.6.87.2-microsoft-standard-WSL2
  • Install method: npm global (~/.npm-global/bin/openclaw)
  • Gateway mode: local loopback
  • Gateway target: ws://127.0.0.1:18789
  • Service: systemd user service openclaw-gateway.service
  • Node used by service: /usr/bin/node

Symptoms

openclaw --version works:

OpenClaw 2026.4.26 (be8c246)

The config validates:

Config valid: ~/.openclaw/openclaw.json

The gateway service is active and logs that the HTTP server is listening:

Service: systemd (enabled)
Command: /usr/bin/node /home/venka/.npm-global/lib/node_modules/openclaw/dist/index.js gateway --port 18789
Gateway: bind=loopback (127.0.0.1), port=18789
Runtime: running (... state active ...)
...
[gateway] http server listening (...; 35.0s)
[gateway] starting channels and sidecars...

But local connectivity checks fail:

Gateway target: ws://127.0.0.1:18789
Source: local loopback
Config: /home/venka/.openclaw/openclaw.json
Bind: loopback

Gateway closed (1006 abnormal closure (no close frame)): no close reason

curl to the dashboard endpoint can also hang despite the port being bound:

curl: (28) Operation timed out after 10032 milliseconds with 0 bytes received

Gateway log evidence

Representative logs after restart:

[gateway] loading configuration…
[gateway] resolving authentication…
[gateway] starting...
[gateway] starting HTTP server...
[canvas] host mounted at http://127.0.0.1:18789/__openclaw__/canvas/
[health-monitor] started
[gateway] agent model: openrouter/tencent/hy3-preview:free
[gateway] http server listening (...; 35.0s)
[gateway] log file: /tmp/openclaw/openclaw-2026-04-28.log
[gateway] starting channels and sidecars...
[hooks] loaded 4 internal hook handlers
[ws] handshake timeout conn=... peer=127.0.0.1:<ephemeral>->127.0.0.1:18789 remote=127.0.0.1
[ws] closed before connect conn=... peer=127.0.0.1:<ephemeral>->127.0.0.1:18789 remote=127.0.0.1 fwd=n/a origin=http://127.0.0.1:18789 host=127.0.0.1:18789 ua=Mozilla/... code=1000 reason=n/a

The service can also become hard to stop gracefully:

Stopping openclaw-gateway.service...
openclaw-gateway.service: State 'stop-sigterm' timed out. Killing.
openclaw-gateway.service: Main process exited, code=killed, status=9/KILL
openclaw-gateway.service: Failed with result 'timeout'.

What was ruled out

  • WSL itself is running (wsl -l -v shows Ubuntu running under WSL2).
  • The OpenClaw binary exists and runs from ~/.npm-global/bin/openclaw.
  • openclaw --version succeeds.
  • openclaw config validate succeeds.
  • The gateway service is active and binds 127.0.0.1:18789.
  • This is not simply “port not listening”; the port is bound, but HTTP/WS readiness is broken.

Possible related issues / PRs

This may overlap with one or both of these current lines of work:

Expected behavior

Local loopback clients should complete the gateway WebSocket connect challenge reliably once the gateway reports listening, or the gateway should not report itself as ready/listening until it can complete local WS handshakes.

Actual behavior

The gateway binds and appears active, but local HTTP/WS clients hang, hit handshake timeout, or close before connect. This makes CLI/dashboard usage unreliable or unusable while the service appears running.

Suggested investigation

  • Confirm whether the v2026.4.25 sidecar startup blocker reported in [Bug]: Regression — channel sidecar startup again blocks for ~3 min after ready on v2026.4.25 (recurrence of #63450) #72846 is still present in v2026.4.26.
  • Check whether channel/sidecar startup or runtime-context/chat-history work can block the WS pre-auth/connect challenge path after HTTP server bind.
  • For WSL specifically, verify whether inherited Windows proxy env vars can still affect local loopback gateway clients in 2026.4.26, even with ws://127.0.0.1:18789.
  • Consider a lightweight readiness probe that verifies the WebSocket connect challenge path, not just port bind / HTTP server creation.

Temporary workarounds to validate

Potential workarounds under investigation:

OPENCLAW_HANDSHAKE_TIMEOUT_MS=30000 openclaw status

and, for WSL/proxy suspicion:

env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy \
  openclaw status

No durable workaround has been confirmed yet for this exact 2026.4.26 WSL setup.

Activity

  1. clawsweeper commented on Apr 28, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Keep open. This is a fresh WSL-specific v2026.4.26 loopback Gateway regression with concrete logs, and current main does not provide strong evidence that the reported bind-then-WebSocket-handshake-timeout path is fixed. The adjacent timeout-config and Windows/WSL proxy PRs are still open, and the earlier sidecar-startup report was closed after a non-repro on main rather than as a shipped WSL fix for this report.

    Best possible solution:

    Keep this open as the WSL v2026.4.26 loopback Gateway handshake regression until maintainers reproduce or disprove it on current main. The most useful next step is to collect OPENCLAW_GATEWAY_STARTUP_TRACE output, /readyz event-loop diagnostics, the systemd service proxy environment, and a literal-127.0.0.1 WebSocket probe from WSL; then land a focused fix in the Gateway sidecar startup path, WSL/proxy handling, or durable timeout configuration with regression coverage for the confirmed failure mode.

    What I checked:

    • Live issue state: GitHub API shows the item is still open, was created 2026-04-28, has no protected labels, and has only the prior ClawSweeper keep-open comment. This is not stale cleanup material.
    • Gateway binds before sidecars finish: Current main attaches Gateway WebSocket handlers before listening, then binds the HTTP server and starts post-attach runtime/sidecars afterward. That removes the old upgrade-handler race but does not rule out the reported post-bind event-loop/sidecar starvation window. (src/gateway/server.impl.ts:928, 891c7d9f1c1f)
    • Sidecars remain startup-gating work: Post-attach runtime starts sidecars after a setImmediate, marks sidecars ready only after that work completes, and by default waits for sidecars before returning. This is still a plausible place for a WSL/systemd event-loop stall to make the port look bound while pre-auth handshakes time out. (src/gateway/server-startup-post-attach.ts:580, 891c7d9f1c1f)
    • Readiness is distinct from HTTP bind/liveness: Readiness stays red with failing=['startup-sidecars'] while sidecars are pending, and the Gateway docs say /healthz is liveness while /readyz is stricter and includes event-loop diagnostics. That matches the report's concern that bind/listening is not enough proof of WebSocket usability. (src/gateway/server/readiness.ts:51, 891c7d9f1c1f)
    • Handshake timeout is still env-only on main: The server pre-auth timeout resolver reads OPENCLAW_HANDSHAKE_TIMEOUT_MS or the Vitest-only fallback and otherwise returns the 10s default. A repository search found no gateway.handshakeTimeoutMs config surface in src/config or gateway docs, and PR feat(gateway): make handshake timeout configurable via gateway.handshakeTimeoutMs #51282 remains open/unmerged. (src/gateway/handshake-timeouts.ts:36, 891c7d9f1c1f)
    • Literal 127.0.0.1 already uses the narrow direct Gateway path: The Gateway client creates a direct agent only for loopback IP literals and wraps that construction in the managed-proxy bypass; tests and public proxy docs also say localhost is intentionally excluded. Since the report uses ws://127.0.0.1:18789, the open localhost/proxy PR is adjacent but not a clear superseding fix for this exact case. (src/gateway/client.ts:96, 891c7d9f1c1f)

    Remaining risk / open question:

    • Exact root cause remains unproven from the checkout alone; plausible causes include WSL/systemd proxy environment, post-bind sidecar event-loop starvation, or insufficient pre-auth/connect-challenge timeout handling.
    • The earlier sidecar-startup report was closed after current-main non-reproduction, but this newer report supplies a WSL2 v2026.4.26 case after that closure, so closing as duplicate or implemented would be premature.
    • Related open PRs address adjacent timeout/proxy symptoms but neither is merged nor clearly validates literal 127.0.0.1 WSL connectivity end to end.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 891c7d9f1c1f.

  2. steipete commented on Apr 29, 2026

    @steipete
    Contributor

    Closing this as fixed on current main by the gateway handshake/startup series:

    • bcc6a24 added the documented gateway.handshakeTimeoutMs config surface, while preserving OPENCLAW_HANDSHAKE_TIMEOUT_MS precedence, so WSL/low-core installs no longer have to patch dist files to raise the pre-auth handshake budget.
    • 7994833 aligned the configured/env handshake budget across local clients, probes, and fallback status RPCs while preserving explicit status timeouts and paired-device auth fallback.
    • 8d58ad4 fixed the bind-before-ready startup window: when sidecars are still pending, WebSocket connect now gets a retryable UNAVAILABLE with details.reason: "startup-sidecars" and retryAfterMs, and Gateway clients retry internally instead of surfacing the old terminal 1006 / handshake-timeout style failure.

    The resulting code path is covered by gateway client, probe, call, browser UI, startup WebSocket connection, and startup race tests, plus the changed gate/docs checks before landing.

    The remaining WSL2 channel transport symptoms (WhatsApp WebSocket/DNS flaps and Telegram polling stalls) are broader than the local Gateway handshake path and remain tracked in #73602. If a fresh main build still shows literal ws://127.0.0.1:18789 Gateway handshake failures outside channel runtime/network stalls, please reopen with new openclaw status --json, /readyz, and gateway logs from the current SHA.

  3. locked as resolved and limited conversation to collaborators on May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions