Skip to content

opencode serve ignores configuration #19078

Closed as not planned
Closed as not planned

Description

@1000p

Description

The opencode serve command appears to ignore the configuration file (tested via passing the OPENCODE_CONFIG environment variable, which resolves to the highest precedence in my configuration).

Example config snippet:

...
{
  "$schema": "https://opencode.ai/config.json",
  "server": {
    "port": 9090,
    "hostname": "0.0.0.0",
...
   }

Results:

The server binds to the loopback interface (127.0.0.1:4096) despite the hostname and port being set to 0.0.0.0:9090 in the provided configuration file.

Expected:

The configuration file provided via OPENCODE_CONFIG should be honored as specified in the server block.

Plugins

N/A

OpenCode version

1.2.27

Steps to reproduce

  1. Opencode with version 1.2.27 installed
  2. Configuration file set using env var OPENCODE_CONFIG as highest precedence
  3. Run opencode serve

Screenshot and/or share link

No response

Operating System

macOS

Terminal

N/A

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 25, 2026
  2. OpeOginni commented on Mar 25, 2026

    @OpeOginni
    Contributor

    @1000p I was able to Reproduce, seems like config for serve command is stuck only using the Global Config, im working on a PR that adds that fact to the docs but also supports use of custom configs set by the OPENCODE_CONFIG variable

  3. added 2 commits that reference this issue on Apr 18, 2026
    7520e61
  4. brian-dlee commented on Apr 18, 2026

    @brian-dlee

    @1000p I use opencode for both personal use and at work and I rely on OPENCODE_CONFIG to alter my configuration between directories. I organically encountered this issue and investigated the code and GitHub issues to find myself here. I see there is another PR aiming to resolve this by @OpeOginni, but I decided to take another stab at it since that one has been waiting for a bit. I aimed to make my attempt at resolving this issue focused, reuse as much of the existing code as possible, and I have been able to verify the functionality on my system. I'm pretty new to open source but I've been in the industry for over a decade. If there is anything you need from me to as far as implementation adjustment or ceremonially in how to go about introducing a change like this, please feel free to nudge me in the right direction.

  5. assigned and unassigned on Apr 26, 2026
  6. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  7. brian-dlee commented on May 11, 2026

    @brian-dlee

    @thdxr @rekram1-node do you have any feedback for this change? I'm on a weekly cadence of rebasing and keeping it up to date currently. I notice the recent activity of removing tags and am just wondering if there is some kind of path forward here. I actively use my fork locally as I have not found any other way for my server config settings to be honored.

  8. Nnyan commented on Jun 30, 2026

    @Nnyan

    Related: #34638 — opencode acp has the same root cause. Both serve and acp are non-TUI subcommands that skip the config initialization pipeline used by CLI/TUI mode. In acp mode, OPENCODE_CONFIG_CONTENT, OPENCODE_CONFIG_DIR, cwd opencode.json, and OPENAI_API_KEY/OPENAI_BASE_URL are all ignored — the ACP subprocess uses only ~/.config/opencode/opencode.json.

    This blocks tooling that launches opencode acp as a subprocess (editors, CI, multi-agent orchestrators like Charon) from injecting per-run provider overrides. The fix for serve (PR #23318?) would likely fix acp as well if it addresses the shared initialization gap.

  9. added a commit that references this issue on Aug 22, 2026
    4cd6c9c
  10. github-actions commented on Aug 30, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions