You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today when i wanted to continue on a project of mine, i could not start opencode for some reason cause of bun i think. i am not sure if its opencodes fault or bun. this is what i got: mattias@Mattiass-MacBook-Pro Beam % arc
1855 | })
1856 | return result
1857 | }
1858 |
1859 | export function listen(opts: { port: number; hostname: string }) {
1860 | const server = Bun.serve({
^
error: Failed to start server. Is port 0 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
at listen (src/server/server.ts:1860:24)
at server (src/cli/cmd/tui/worker.ts:36:23)
at server (src/cli/cmd/tui/worker.ts:33:16)
at <anonymous> (src/util/rpc.ts:10:41)
at onmessage (src/util/rpc.ts:7:24)
OpenCode version
1.0.203
Steps to reproduce
go in to any directory
type start opencode
and get the error
Screenshot and/or share link
Operating System
MacOS 21.1
Terminal
The cursor terminal and the default terminal that comes with macos
Still doesnt work even if i use other ports that are free on my system:
mattias@Mattiass-MacBook-Pro Beam % opencode --
port 5811
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 5811 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
at listen (src/server/server.ts:2078:24)
at server (src/cli/cmd/tui/worker.ts:34:23)
at server (src/cli/cmd/tui/worker.ts:31:16)
at <anonymous> (src/util/rpc.ts:10:41)
at onmessage (src/util/rpc.ts:7:24)
i do not have many files open. i recently restarted my system and tried again but it still did not work.
mattias@Mattiass-MacBook-Pro Beam % pkill -f opencode
mattias@Mattiass-MacBook-Pro Beam % opencode
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 0 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
at listen (src/server/server.ts:2078:24)
at server (src/cli/cmd/tui/worker.ts:34:23)
at server (src/cli/cmd/tui/worker.ts:31:16)
at <anonymous> (src/util/rpc.ts:10:41)
at onmessage (src/util/rpc.ts:7:24)
Hello, thanks for the reply but i have ran all of your commands now and i will paste them bellow: mattias@Mattiass-MacBook-Pro Beam % bun --version
1.3.3
mattias@Mattiass-MacBook-Pro Beam % ls -la ~/.local/bin/opencode
ls -la ~/.opencode/bin/
ls: /Users/mattias/.local/bin/opencode: No such file or directory
total 186592
drwxr-xr-x@ 3 mattias staff 96 Dec 26 18:36 .
drwxr-xr-x@ 7 mattias staff 224 Dec 21 23:04 ..
-rwxr-xr-x@ 1 mattias staff 95534832 Dec 26 05:08 opencode
mattias@Mattiass-MacBook-Pro Beam % echo "Bun.serve({ port: 9999, fetch: () => new Response("ok") }); console.log("works")" | bun run -
works
^C
mattias@Mattiass-MacBook-Pro Beam % That command just hangs
zsh: command not found: That
mattias@Mattiass-MacBook-Pro Beam % sudo opencode
Password:
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 0 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
at listen (src/server/server.ts:2078:24)
at server (src/cli/cmd/tui/worker.ts:34:23)
at server (src/cli/cmd/tui/worker.ts:31:16)
at <anonymous> (src/util/rpc.ts:10:41)
at onmessage (src/util/rpc.ts:7:24)
mattias@Mattiass-MacBook-Pro Beam % npm i -g opencode-ai
changed 2 packages in 3s
npm notice
npm notice New major version of npm available! 10.8.2 -> 11.7.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.7.0
npm notice To update run: npm install -g npm@11.7.0
npm notice
mattias@Mattiass-MacBook-Pro Beam % opencode
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 0 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
at listen (src/server/server.ts:2078:24)
at server (src/cli/cmd/tui/worker.ts:34:23)
at server (src/cli/cmd/tui/worker.ts:31:16)
at <anonymous> (src/util/rpc.ts:10:41)
at onmessage (src/util/rpc.ts:7:24)
error: Failed to start server. Is port 9999 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
at serve (unknown:1:1)
at src/cli/cmd/tui/spawn.ts:27:27
at handler (src/cli/cmd/tui/spawn.ts:25:19)
at ../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:245:54
at processTicksAndRejections (native:7:39)
The error is happening inside Bun's native serve function (at serve (unknown:1:1)), not opencode itself. Port 9999 isn't in use, so this looks like a Bun bug on macOS 26.
Ok. But something is weird cause it worked before but just not now: mattias@Mattiass-MacBook-Pro Beam % cat /Users/mattias/.local/share/opencode/log/2025-12-26T183500.log
INFO 2025-12-26T18:35:00 +630ms service=default version=1.0.203 args=["spawn","--port","9999"] opencode
INFO 2025-12-26T18:35:00 +0ms service=config path=/Users/mattias/.config/opencode/config.json loading
ERROR 2025-12-26T18:35:00 +8ms service=default name=Error message=Failed to start server. Is port 9999 in use? stack=Error: Failed to start server. Is port 9999 in use?
at serve (unknown)
at (src/cli/cmd/tui/spawn.ts:27:27)
at handler (src/cli/cmd/tui/spawn.ts:25:19)
at (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:245:54)
at processTicksAndRejections (native:7:39) fatal
mattias@Mattiass-MacBook-Pro Beam % bun upgrade
Bun v1.3.5 is out! You're on v1.3.3
[2.43s] Upgraded.
mattias@Mattiass-MacBook-Pro Beam % opencode
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 0 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
at listen (src/server/server.ts:2078:24)
at server (src/cli/cmd/tui/worker.ts:34:23)
at server (src/cli/cmd/tui/worker.ts:31:16)
at <anonymous> (src/util/rpc.ts:10:41)
at onmessage (src/util/rpc.ts:7:24)
btw your local bun version shoudl have nothing to do w/ opencode, opencode has bun built into it so unless u are messing w/ bun env vars or special configs u shouldnt need to run bun upgrade ever (or even have it installed!)
Activity
rekram1-node commentedon Dec 26, 2025
What if you try running like:
opencode --port 5811or something that'd be free?mattiasmicu commentedon Dec 26, 2025
Still doesnt work even if i use other ports that are free on my system:
mattias@Mattiass-MacBook-Pro Beam % opencode --
port 5811
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 5811 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
rekram1-node commentedon Dec 26, 2025
Do u have too many open files or something?
maybe try:
pkill -f opencode
And then try again
mattiasmicu commentedon Dec 26, 2025
i do not have many files open. i recently restarted my system and tried again but it still did not work.
mattias@Mattiass-MacBook-Pro Beam % pkill -f opencode
mattias@Mattiass-MacBook-Pro Beam % opencode
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 0 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
anntnzrb commentedon Dec 26, 2025
This looks like corrupted state rather than an actual port conflict (errno: 0 is unusual). Try these in order:
rm -rf ~/.bun/install/cachecurl -fsSL https://opencode.ai/install | bashAlso check if any firewall/security software (Little Snitch, Lulu, etc.) might be blocking socket creation.
Let us know if that helps!
mattiasmicu commentedon Dec 26, 2025
i have tried EVERY thing that you have listed there and still i am getting the same error as before.
anntnzrb commentedon Dec 26, 2025
A few more things to check:
The
errno: 0is very unusual — it might mean Bun is misreporting anEACCES(permission denied) asEADDRINUSE.mattiasmicu commentedon Dec 26, 2025
Hello, thanks for the reply but i have ran all of your commands now and i will paste them bellow: mattias@Mattiass-MacBook-Pro Beam % bun --version
1.3.3
mattias@Mattiass-MacBook-Pro Beam % ls -la ~/.local/bin/opencode
ls -la ~/.opencode/bin/
ls: /Users/mattias/.local/bin/opencode: No such file or directory
total 186592
drwxr-xr-x@ 3 mattias staff 96 Dec 26 18:36 .
drwxr-xr-x@ 7 mattias staff 224 Dec 21 23:04 ..
-rwxr-xr-x@ 1 mattias staff 95534832 Dec 26 05:08 opencode
mattias@Mattiass-MacBook-Pro Beam % echo "Bun.serve({ port: 9999, fetch: () => new Response("ok") }); console.log("works")" | bun run -
works
^C
mattias@Mattiass-MacBook-Pro Beam % That command just hangs
zsh: command not found: That
mattias@Mattiass-MacBook-Pro Beam % sudo opencode
Password:
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 0 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
^C%
mattias@Mattiass-MacBook-Pro Beam %
anntnzrb commentedon Dec 26, 2025
Good news: your system Bun works fine (the test printed "works"). The issue is specific to opencode's bundled runtime.
A few more diagnostics:
~/.opencode/bin/opencode --versionIf npm install works but curl doesn't, the bundled Bun binary might be incompatible with your macOS version.
mattiasmicu commentedon Dec 26, 2025
ok i have ran you commands again. but macos 21.1 exists but its also called macos Tahoe.
mattias@Mattiass-MacBook-Pro Beam % sw_vers
ProductName: macOS
ProductVersion: 26.1
BuildVersion: 25B78
mattias@Mattiass-MacBook-Pro Beam % ~/.opencode/bin/opencode --version
1.0.203
mattias@Mattiass-MacBook-Pro Beam % mv ~/.opencode ~/.opencode.bak
curl -fsSL https://opencode.ai/install | bash
Installed version: .
Installing opencode version: 1.0.203
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 100%
█▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
█░░█ █░░█ █▀▀▀ █░░█ █░░░ █░░█ █░░█ █▀▀▀
▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀ ▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀
OpenCode includes free models, to start:
cd # Open directory
opencode # Run command
For more information visit https://opencode.ai/docs
mattias@Mattiass-MacBook-Pro Beam % npm i -g opencode-ai
changed 2 packages in 3s
npm notice
npm notice New major version of npm available! 10.8.2 -> 11.7.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.7.0
npm notice To update run: npm install -g npm@11.7.0
npm notice
mattias@Mattiass-MacBook-Pro Beam % opencode
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 0 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
^C%
mattias@Mattiass-MacBook-Pro Beam %
anntnzrb commentedon Dec 26, 2025
Since system Bun works but opencode fails, let's see what's happening on your system:
netstat -an | grep LISTENulimit -nps aux | grep -i opencode~/.opencode/bin/opencode spawn --port 9999Also — do you have any VPN, antivirus, or security software running (Cisco AnyConnect, Little Snitch, etc.)?
mattiasmicu commentedon Dec 26, 2025
Sorry for the wait i was away but here it is: mattias@Mattiass-MacBook-Pro Beam % netstat -an | grep LISTEN
tcp6 0 0 *.54907 . LISTEN
tcp4 0 0 *.54907 . LISTEN
tcp46 0 0 *.58987 . LISTEN
tcp46 0 0 *.3283 . LISTEN
tcp6 0 0 *.5000 . LISTEN
tcp4 0 0 *.5000 . LISTEN
tcp6 0 0 *.7000 . LISTEN
tcp4 0 0 *.7000 . LISTEN
tcp46 0 0 *.58986 . LISTEN
tcp4 0 0 *.88 . LISTEN
tcp6 0 0 *.88 . LISTEN
tcp6 0 0 ::1.8021 . LISTEN
tcp4 0 0 *.5900 . LISTEN
tcp6 0 0 *.5900 . LISTEN
tcp4 0 0 *.22 . LISTEN
tcp6 0 0 *.22 . LISTEN
mattias@Mattiass-MacBook-Pro Beam % ulimit -n
1048575
mattias@Mattiass-MacBook-Pro Beam % ps aux | grep -i opencode
mattias 56543 0.0 0.0 435300064 1296 s001 S+ 7:34PM 0:00.00 grep -i opencode
mattias@Mattiass-MacBook-Pro Beam % ~/.opencode/bin/opencode spawn --port 9999
Error: Unexpected error, check log file at /Users/mattias/.local/share/opencode/log/2025-12-26T183500.log for more details
error: Failed to start server. Is port 9999 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
mattias@Mattiass-MacBook-Pro Beam %
anntnzrb commentedon Dec 26, 2025
The error is happening inside Bun's native
servefunction (at serve (unknown:1:1)), not opencode itself. Port 9999 isn't in use, so this looks like a Bun bug on macOS 26.Can you:
mattiasmicu commentedon Dec 26, 2025
Ok. But something is weird cause it worked before but just not now: mattias@Mattiass-MacBook-Pro Beam % cat /Users/mattias/.local/share/opencode/log/2025-12-26T183500.log
INFO 2025-12-26T18:35:00 +630ms service=default version=1.0.203 args=["spawn","--port","9999"] opencode
INFO 2025-12-26T18:35:00 +0ms service=config path=/Users/mattias/.config/opencode/config.json loading
ERROR 2025-12-26T18:35:00 +8ms service=default name=Error message=Failed to start server. Is port 9999 in use? stack=Error: Failed to start server. Is port 9999 in use?
at serve (unknown)
at (src/cli/cmd/tui/spawn.ts:27:27)
at handler (src/cli/cmd/tui/spawn.ts:25:19)
at (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:245:54)
at processTicksAndRejections (native:7:39) fatal
mattias@Mattiass-MacBook-Pro Beam % bun upgrade
Bun v1.3.5 is out! You're on v1.3.3
[2.43s] Upgraded.
Welcome to Bun v1.3.5!
What's new in Bun v1.3.5:
Report any bugs:
Commit log:
mattias@Mattiass-MacBook-Pro Beam % opencode
2073 | })
2074 | return result
2075 | }
2076 |
2077 | export function listen(opts: { port: number; hostname: string }) {
2078 | const server = Bun.serve({
^
error: Failed to start server. Is port 0 in use?
syscall: "listen",
errno: 0,
code: "EADDRINUSE"
^C%
mattias@Mattiass-MacBook-Pro Beam %
rekram1-node commentedon Dec 26, 2025
btw your local bun version shoudl have nothing to do w/ opencode, opencode has bun built into it so unless u are messing w/ bun env vars or special configs u shouldnt need to run bun upgrade ever (or even have it installed!)
mattiasmicu commentedon Dec 26, 2025
then what do i do?
mattiasmicu commentedon Dec 26, 2025
and i have not messed with anything
mattiasmicu commentedon Dec 26, 2025
I have found a fix. I had do update my device from 21.1 to 21.2. But thanks for helping!