opencode --port=8080 fails because port statically bound to 4096 #3737

Closed
opened 2026-02-16 17:41:17 -05:00 by yindo · 3 comments
Owner

Originally created by @kulesh on GitHub (Dec 21, 2025).

Originally assigned to: @adamdotdevin on GitHub.

Description

Was trying to test open code web interface per https://x.com/thdxr/status/2002786192534991106 and found that opencode won't work on ports other than 4096 (opencode --port=8080, for example).

In packages/desktop/src/app.tsx, when location.hostname includes "localhost", the code builds the URL using hardcoded values instead of using relative URLs that would resolve to the actual server origin.

A possible fix, thanks to Opencode+CC, is here: https://github.com/kulesh/opencode/pull/1/files but I am not sure if that's an acceptable/proper fix.

OpenCode version

1.0.185

Steps to reproduce

  1. Run opencode --port=8080
  2. Open http://localhost:8080 in browser
  3. Open DevTools Network tab
  4. Observe API calls going to http://127.0.0.1:4096 instead of port 8080

Screenshot and/or share link

Image

Operating System

macOS 26.1

Terminal

Ghostty

Originally created by @kulesh on GitHub (Dec 21, 2025). Originally assigned to: @adamdotdevin on GitHub. ### Description Was trying to test open code web interface per https://x.com/thdxr/status/2002786192534991106 and found that opencode won't work on ports other than 4096 (`opencode --port=8080`, for example). In `packages/desktop/src/app.tsx`, when `location.hostname` includes "localhost", the code builds the URL using hardcoded values instead of using relative URLs that would resolve to the actual server origin. A possible fix, thanks to Opencode+CC, is here: https://github.com/kulesh/opencode/pull/1/files but I am not sure if that's an acceptable/proper fix. ### OpenCode version 1.0.185 ### Steps to reproduce 1. Run `opencode --port=8080` 2. Open `http://localhost:8080` in browser 3. Open DevTools Network tab 4. Observe API calls going to `http://127.0.0.1:4096` instead of port 8080 ### Screenshot and/or share link <img width="1349" height="756" alt="Image" src="https://github.com/user-attachments/assets/92d0d7bb-5de8-4434-ada3-c69d9df6c3cd" /> ### Operating System macOS 26.1 ### Terminal Ghostty
yindo added the bugweb labels 2026-02-16 17:41:17 -05:00
yindo closed this issue 2026-02-16 17:41:17 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 21, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #5844: Bug: Web terminal fails when accessing via network IP instead of localhost

Both issues describe the same root cause in packages/desktop/src/app.tsx where the code builds the URL using hardcoded values instead of using the actual server origin. Feel free to ignore if your specific case differs.

@github-actions[bot] commented on GitHub (Dec 21, 2025): This issue might be a duplicate of existing issues. Please check: - #5844: Bug: Web terminal fails when accessing via network IP instead of localhost Both issues describe the same root cause in `packages/desktop/src/app.tsx` where the code builds the URL using hardcoded values instead of using the actual server origin. Feel free to ignore if your specific case differs.
Author
Owner

@thdxr commented on GitHub (Dec 22, 2025):

the issue was localhost was treated differently than 127.0.0.1. fixed now

@thdxr commented on GitHub (Dec 22, 2025): the issue was `localhost` was treated differently than `127.0.0.1`. fixed now
Author
Owner

@gempir commented on GitHub (Dec 23, 2025):

I think this is still broken? https://github.com/sst/opencode/pull/5949 was reverted

On 1.0.193 I'm still having the issue.

@gempir commented on GitHub (Dec 23, 2025): I think this is still broken? https://github.com/sst/opencode/pull/5949 was reverted On 1.0.193 I'm still having the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3737