Repository navigation
Description
Description
When trying to start opencode in WSL Ubuntu following error appears:
Error: Server process exited with code 1
Error: Managed service port 49374 on 127.0.0.1 is already in use by another process. Configure another port with `opencode service set port <port>` and start the service again.
at <anonymous> (/$bunfs/root/chunk-x6242730.js:2:8786) {
[cause]: ServeError:
at N (/$bunfs/root/chunk-q8wzwtww.js:52:7706)
at applyHandlers (node:events:64:20)
at emitError (node:events:44:27)
at emitListenErrorNextTick (node:_http_server:134:12)
at processTicksAndRejections (unknown:7:39) {
[cause]: Error: Failed to start server. Is port 49374 in use?
at serve (unknown)
at <anonymous> (node:_http_server:359:39)
at <anonymous> (node:_http_server:332:33)
at <anonymous> (/$bunfs/root/chunk-q8wzwtww.js:52:7744)
}
}
at map (unknown:1:11)
at reap (/$bunfs/root/chunk-b5fy5cjh.js:2:1203)
at <anonymous> (/$bunfs/root/chunk-b5fy5cjh.js:3:6711)
at service.ensure (/$bunfs/root/chunk-tbc1ctg4.js:3:690)
at service.ensure (definition) (/$bunfs/root/chunk-b5fy5cjh.js:3:5523)
at cli.server-connection.resolve (/$bunfs/root/chunk-r0qkjn9z.js:96:6563)
at cli.server-connection.resolve (definition) (/$bunfs/root/chunk-tbc1ctg4.js:2:402)
This issue arises when opencode tries to use it's own default port or configuring a own port.
I've read in another open issue that a potential cause for this could be the port generation of opencode and what WSL / Windows reserves for some HyperV stuff. Thus i tried to set the port myself using opencode service set port in different ranges, all to no avail.
Maybe the issue is another with my networking mode on wsl being mirrored. It looks like the background service can be started, it's not alive from opencodes standpoint and tries to restart it.
Here the logs from my attempts using different ports and the opencode assigned port:
timestamp=2026-10-16T05:46:35.320Z level=ERROR run=04f5b91d message="cli process failed" cause="Cause([Fail(Error: Managed service port 49374 on 127.0.0.1 is already in use by another process. Configure another port with `opencode service set port <port>` and start the service again. (cause: ServeError (cause: Error: Failed to start server. Is port 49374 in use?)))])" args="[\"serve\",\"--service\"]" role=cli
timestamp=2026-10-16T05:48:14.928Z level=ERROR run=9f177f90 message="cli process failed" cause="Cause([Fail(Error: Server process exited with code 1\nError: Managed service port 49374 on 127.0.0.1 is already in use by another process. Configure another port with `opencode service set port <port>` and start the service again.\n at <anonymous> (/$bunfs/root/chunk-x6242730.js:2:8786) {\n [cause]: ServeError: \n at N (/$bunfs/root/chunk-q8wzwtww.js:52:7706)\n at applyHandlers (node:events:64:20)\n at emitError (node:events:44:27)\n at emitListenErrorNextTick (node:_http_server:134:12)\n at processTicksAndRejections (unknown:7:39) {\n [cause]: Error: Failed to start server. Is port 49374 in use?\n at serve (unknown)\n at <anonymous> (node:_http_server:359:39)\n at <anonymous> (node:_http_server:332:33)\n at <anonymous> (/$bunfs/root/chunk-q8wzwtww.js:52:7744)\n }\n})])" args=[] role=cli
timestamp=2026-10-16T05:51:02.104Z level=INFO run=560dc207 message="cli starting" version=2.0.29 channel=latest local=false args="[\"--version\"]" role=cli
timestamp=2026-10-16T05:55:04.009Z level=INFO run=8b76da0e message="cli starting" version=2.0.29 channel=latest local=false args="[\"service\",\"set\",\"port\",\"12000\"]" role=cli
timestamp=2026-10-16T05:55:06.432Z level=INFO run=cab7c3cb message="cli starting" version=2.0.29 channel=latest local=false args=[] role=cli
timestamp=2026-10-16T05:55:06.506Z level=INFO run=cab7c3cb message="background service starting" reason=missing previousVersion=undefined role=cli
timestamp=2026-10-16T05:55:06.572Z level=INFO run=5b9a17d1 message="cli starting" version=2.0.29 channel=latest local=false args="[\"serve\",\"--service\"]" role=cli
timestamp=2026-10-16T05:55:11.581Z level=INFO run=798b104a message="cli starting" version=2.0.29 channel=latest local=false args="[\"serve\",\"--service\"]" role=cli
timestamp=2026-10-16T05:55:26.791Z level=ERROR run=798b104a message="cli process failed" cause="Cause([Fail(Error: Managed service port 12000 on 127.0.0.1 is already in use by another process. Configure another port with `opencode service set port <port>` and start the service again. (cause: ServeError (cause: Error: Failed to start server. Is port 12000 in use?)))])" args="[\"serve\",\"--service\"]" role=cli
timestamp=2026-10-16T05:57:06.550Z level=ERROR run=cab7c3cb message="cli process failed" cause="Cause([Fail(Error: Server process exited with code 1\nError: Managed service port 12000 on 127.0.0.1 is already in use by another process. Configure another port with `opencode service set port <port>` and start the service again.\n at <anonymous> (/$bunfs/root/chunk-x6242730.js:2:8786) {\n [cause]: ServeError: \n at N (/$bunfs/root/chunk-q8wzwtww.js:52:7706)\n at applyHandlers (node:events:64:20)\n at emitError (node:events:44:27)\n at emitListenErrorNextTick (node:_http_server:134:12)\n at processTicksAndRejections (unknown:7:39) {\n [cause]: Error: Failed to start server. Is port 12000 in use?\n at serve (unknown)\n at <anonymous> (node:_http_server:359:39)\n at <anonymous> (node:_http_server:332:33)\n at <anonymous> (/$bunfs/root/chunk-q8wzwtww.js:52:7744)\n }\n})])" args=[] role=cli
timestamp=2026-10-16T05:59:34.209Z level=INFO run=d1751cac message="cli starting" version=2.0.29 channel=latest local=false args="[\"service\",\"set\",\"port\",\"65891\"]" role=cli
timestamp=2026-10-16T05:59:34.214Z level=ERROR run=d1751cac message="cli process failed" cause="Cause([Die(Error: Port must be between 1 and 65535)])" args="[\"service\",\"set\",\"port\",\"65891\"]" role=cli
timestamp=2026-10-16T05:59:42.297Z level=INFO run=4b451abb message="cli starting" version=2.0.29 channel=latest local=false args="[\"service\",\"set\",\"port\",\"64256\"]" role=cli
timestamp=2026-10-16T05:59:46.790Z level=INFO run=ac5519f6 message="cli starting" version=2.0.29 channel=latest local=false args=[] role=cli
timestamp=2026-10-16T05:59:46.857Z level=INFO run=ac5519f6 message="background service starting" reason=missing previousVersion=undefined role=cli
timestamp=2026-10-16T05:59:46.921Z level=INFO run=b7bff5f6 message="cli starting" version=2.0.29 channel=latest local=false args="[\"serve\",\"--service\"]" role=cli
timestamp=2026-10-16T05:59:51.988Z level=INFO run=9422340f message="cli starting" version=2.0.29 channel=latest local=false args="[\"serve\",\"--service\"]" role=cli
timestamp=2026-10-16T06:00:07.288Z level=ERROR run=9422340f message="cli process failed" cause="Cause([Fail(Error: Managed service port 64256 on 127.0.0.1 is already in use by another process. Configure another port with `opencode service set port <port>` and start the service again. (cause: ServeError (cause: Error: Failed to start server. Is port 64256 in use?)))])" args="[\"serve\",\"--service\"]" role=cli
timestamp=2026-10-16T06:01:46.911Z level=ERROR run=ac5519f6 message="cli process failed" cause="Cause([Fail(Error: Server process exited with code 1\nError: Managed service port 64256 on 127.0.0.1 is already in use by another process. Configure another port with `opencode service set port <port>` and start the service again.\n at <anonymous> (/$bunfs/root/chunk-x6242730.js:2:8786) {\n [cause]: ServeError: \n at N (/$bunfs/root/chunk-q8wzwtww.js:52:7706)\n at applyHandlers (node:events:64:20)\n at emitError (node:events:44:27)\n at emitListenErrorNextTick (node:_http_server:134:12)\n at processTicksAndRejections (unknown:7:39) {\n [cause]: Error: Failed to start server. Is port 64256 in use?\n at serve (unknown)\n at <anonymous> (node:_http_server:359:39)\n at <anonymous> (node:_http_server:332:33)\n at <anonymous> (/$bunfs/root/chunk-q8wzwtww.js:52:7744)\n }\n})])" args=[] role=cli
Starting the background server using opencode serve does work though. So i think the issue is that TUI cannot attach to the background server and maybe tries to restart it? I don't think the issue is with the server itself based on this behaviour.
Plugins
None
OpenCode version
2.0.29
Steps to reproduce
- Install opencode 2.0.29
- Start opencode tui via
opencode
Screenshot and/or share link
No response
Operating System
WSL Ubuntu 24.04.4 LTS
Terminal
Windows Terminal for opening WSL. WSL uses bash
Activity
[-]Opencode TUI cannot be started in opencode v2[/-][+]Opencode TUI cannot be started with opencode v2[/+]opencode-agent commentedon Oct 16, 2026
Thanks for the detailed logs, they made this much easier to track down. I could reproduce the same failure on 2.0.29, and it still happens on the latest
dev(f09eee5). In my case the cause was an HTTP proxy set in the environment.What happens:
http://127.0.0.1:<port>, but becauseHTTP_PROXY/http_proxyis set andNO_PROXYisn't, that check goes through the proxy and never reaches the service.This matches your logs exactly, including the timing, and explains why
opencode serveon its own works.Could you check whether proxy variables are set in your WSL shell? WSL can set them automatically when it copies the Windows proxy settings:
env | grep -i proxyIf they are, this should work around it for now:
export NO_PROXY=127.0.0.1,localhost no_proxy=127.0.0.1,localhost opencodeThe script below reproduces it with an unreachable proxy.
Related issues, most closely related first:
Reproduction script (repro.sh)
Run it:
bash repro.shDaniloMurer commentedon Oct 16, 2026
Yes the issue is with Proxy env variables. I had no NO_PROXY env variable set. After setting it to
NO_PROXY=127.0.0.1the TUI worked as expected