Description
The gateway fails to start when WSL2 is configured with networkingMode=mirrored in .wslconfig. It enters an infinite crash loop with the error:
Gateway failed to start: another gateway instance is already listening on ws://127.0.0.1:18789
Environment
- OS: Windows 11 + WSL2 (Ubuntu)
- OpenClaw: 2026.3.22 (4dcc39c)
- Node.js: v22.22.0
- WSL config:
networkingMode=mirrored in C:\Users\<user>\.wslconfig
Root Cause
The gateway startup sequence:
- Binds the canvas HTTP server on the configured port (e.g., 18789) — succeeds
- Probes
ws://127.0.0.1:18789 via WebSocket to check for competing gateway instances
- Under mirrored networking, this probe routes through the Windows network stack instead of staying within WSL loopback
- The probe hits the gateway's own canvas HTTP server (which is already bound but not yet serving WebSocket)
- Receives a non-WebSocket HTTP response
- Concludes another gateway instance is running → aborts startup
Reproduction
- Enable mirrored networking in
.wslconfig:
[wsl2]
networkingMode=mirrored
wsl --shutdown and reopen WSL
- Start the OpenClaw gateway:
openclaw gateway start
- Observe crash loop in
journalctl --user -u openclaw-gateway
Confirmation
- Tested on an alternate port (18800) — same failure, proving no external process is involved
- The gateway is detecting itself through the mirrored network path
ss -tlnp and lsof show no competing process on the port
- Disabling mirrored networking resolves the issue immediately
Workaround
Comment out networkingMode=mirrored in .wslconfig and restart WSL. This forces WSL2 back to NAT mode where loopback stays within the Linux network namespace.
Suggested Fix
The self-probe should either:
- Bind the WebSocket listener before probing, so the probe hits the actual WS endpoint
- Use a different mechanism to detect competing instances (e.g., PID file, named socket, or flock)
- Skip the WS probe when the canvas HTTP server was just bound by the current process
- Add a short delay or retry with WS-specific validation before concluding another instance exists
Impact
WSL2 mirrored networking is increasingly common (it simplifies localhost sharing between Windows and WSL). This bug forces users to disable a useful networking feature to run OpenClaw.
Description
The gateway fails to start when WSL2 is configured with
networkingMode=mirroredin.wslconfig. It enters an infinite crash loop with the error:Environment
networkingMode=mirroredinC:\Users\<user>\.wslconfigRoot Cause
The gateway startup sequence:
ws://127.0.0.1:18789via WebSocket to check for competing gateway instancesReproduction
.wslconfig:wsl --shutdownand reopen WSLopenclaw gateway startjournalctl --user -u openclaw-gatewayConfirmation
ss -tlnpandlsofshow no competing process on the portWorkaround
Comment out
networkingMode=mirroredin.wslconfigand restart WSL. This forces WSL2 back to NAT mode where loopback stays within the Linux network namespace.Suggested Fix
The self-probe should either:
Impact
WSL2 mirrored networking is increasingly common (it simplifies localhost sharing between Windows and WSL). This bug forces users to disable a useful networking feature to run OpenClaw.