Skip to content

Cannot use opencode attach when OPENCODE_SERVER_USERNAME set #25113

Closed

Description

@jasonwch

Description

From this #9095

Am I able to use this to attach the web server like this?
OPENCODE_SERVER_USERNAME="username" OPENCODE_SERVER_PASSWORD="password" opencode attach http://localhost:4096

But when I do this, it's still showing Unauthorized. Am I miss anything?

Plugins

Nil

OpenCode version

1.14.30

Steps to reproduce

use this command on terminal:
OPENCODE_SERVER_USERNAME="username" OPENCODE_SERVER_PASSWORD="password" opencode attach http://localhost:4096

shows Unauthorized

Screenshot and/or share link

NIL

Operating System

Ubuntu 24.04

Terminal

Termius

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 30, 2026
  2. github-actions commented on Apr 30, 2026

    @github-actions
    Contributor

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

    If your issue is distinct from these, please add more detail explaining the difference.

  3. OpeOginni commented on Apr 30, 2026

    @OpeOginni
    Contributor

    How did you start the server?

  4. jasonwch commented on Apr 30, 2026

    @jasonwch
    Author

    How did you start the server?

    I use this method to start as service
    https://gist.github.com/shawnyeager/752ce43e4f8d97f55cd9db397544873f

  5. davereed commented on May 1, 2026

    @davereed

    It's not well documented, but you can do:

    opencode attach http://ip:port -p password

  6. jasonwch commented on May 1, 2026

    @jasonwch
    Author

    It's not well documented, but you can do:

    opencode attach http://ip:port -p password

    I mean I have custom username by OPENCODE_SERVER_USERNAME as well

  7. davereed commented on May 2, 2026

    @davereed

    It seems to be hardcoded to the default 'opencode' username. I think your only option would be to unset the custom username.

    const auth = `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}`

  8. OpeOginni commented on May 2, 2026

    @OpeOginni
    Contributor

    It seems to be hardcoded to the default 'opencode' username. I think your only option would be to unset the custom username.

    const auth = `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}`

    Noticed that too, would need to alert the team

  9. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  10. SrHenry commented on May 3, 2026

    @SrHenry

    Makes no sense to have a environment variable like OPENCODE_SERVER_USERNAME if you can't use it anywhere but the Web UI. PR #9095 fixed it ages ago but never got merged

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