Repository navigation
Description
Description
Summary
When a system proxy is active (WSL2 networkingMode=Mirrored auto-syncs HTTP_PROXY/no_proxy into every WSL process), service discovery can transiently fail and multiple concurrently starting CLI instances each spawn serve --service; the losers die with Managed service port 49375 ... already in use.
Two related defects:
- Without
NO_PROXY, requests to127.0.0.1are routed through the proxy — loopback should be excluded unconditionally. - Concurrent service spawns are not mutually exclusive, so a transient discovery failure surfaces as a confusing "port already in use" error.
Actual Behavior
Log timeline (2026-10-19, ~/.local/share/opencode/log/opencode.log; 49 occurrences between 10-12 and 10-19 on versions 2.0.29–2.0.32):
06:53:13 event stream disconnected (socket closed unexpectedly)
06:53:18/23/36 three serve --service spawned within 18s
06:53:31 background service starting reason=missing
06:53:34~51 all three die: "Managed service port 49375 on 127.0.0.1 is already in
use by another process ... (cause: ServeError: Failed to start server.
Is port 49375 in use?)"
06:54~07:04 external fetches (models.opencode.ai) fail while proxy restarts
Second occurrence the same day:
07:43:48 background service starting reason=missing → spawn #1 (succeeds)
07:43:53 spawn #2 five seconds later
07:44:09 spawn #2 dies: "Managed service port 49375 ... already in use"
Expected Behavior
- Health/discovery requests to
127.0.0.1should never go through a proxy, even whenNO_PROXYis absent or malformed. - Concurrent service starts should be mutually exclusive (per-port spawn lock); losing starters should wait and attach to the already-running service instead of erroring.
Probe experiment
With a deliberately dead proxy (HTTP_PROXY=http://127.0.0.1:1), running opencode api get /api/info:
| env | result |
|---|---|
no NO_PROXY |
❌ fails — localhost request is sent to the proxy |
NO_PROXY=127.0.0.1 |
✅ direct |
NO_PROXY=127.*,localhost,<local> (Windows-style, as synced by WSL) |
✅ direct |
Additional Context
- Environment: WSL2 with
networkingMode=Mirrored; Windows Clash system proxy at127.0.0.1:7890; the registryProxyOverridebypass list only affects WinINET consumers, not Node/Bun programs readingHTTP_PROXY. - Workarounds: pin
NO_PROXY=127.0.0.1,localhost,::1in the shell profile; avoid toggling the proxy while starting opencode; avoid launching multiple instances simultaneously. - Suggested fix: unconditionally exclude loopback in the HTTP client used for service discovery, and guard spawn with a per-port lock so losers poll-attach.
Plugins
none
OpenCode version
2.0.32 (also reproduced on 2.0.29–2.0.31)
Steps to reproduce
- Enable a system HTTP proxy on Windows (e.g. Clash at
127.0.0.1:7890); WSL2 mirrored networking syncsHTTP_PROXY/no_proxyinto every WSL process. - Toggle/restart the proxy (a few seconds of connectivity loss), and/or start several opencode instances at once during that window.
- A CLI logs
background service starting reason=missing. - Multiple
serve --serviceprocesses race; the first binds port 49375, the rest fail with EADDRINUSE.
Screenshot
No response
Operating System
Linux 6.6.87.2-microsoft-standard-WSL2 (WSL2, networkingMode=Mirrored), x86_64 — Windows host
Terminal
Windows Terminal / xterm-256color, shell /bin/bash
Activity
opencode-agent commentedon Oct 19, 2026
Thanks for the detailed timeline and the probe experiment, they make the cause clear.
I think this is a duplicate of #52054. When
HTTP_PROXYis set andNO_PROXYdoesn't exempt loopback, the client sends its health and discovery requests to its own background service on127.0.0.1through the proxy. When that request fails, the client decides the service ismissingand starts anotherserve --service, which then fails with "Managed service port ... already in use". Your table shows the same thing: noNO_PROXYfails,NO_PROXY=127.0.0.1works.Possible duplicates and related issues, ordered by likelihood:
127.0.0.1go throughHTTP_PROXYwhenno_proxyis unset, which leads to repeated service restarts.missingand starts another one on the fixed port instead of attaching to the one already running.XDG_STATE_HOME.Until this is fixed, your workaround of exporting
NO_PROXY=127.0.0.1,localhost,::1(andno_proxytoo) in your shell profile is the most reliable option.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
opencode-agent commentedon Oct 20, 2026
Closing this as a duplicate of #52054, since we haven't heard otherwise in the last day. Both are about the client sending requests to its own background service on
127.0.0.1throughHTTP_PROXY. Please follow #52054 for progress on the proxy problem, and #54267 for the second point: a new client starting another service instead of attaching to the one already running.Until it's fixed, exporting
NO_PROXY=127.0.0.1,localhost,::1(andno_proxy) in your shell profile should avoid the problem. If your case turns out to be different, reply here and we can reopen it. Thanks again for the detailed timeline and probe results.