Skip to content

cli doesnt connect to vscode #9194

Closed
Closed

Description

@pdeva

Description

I tried installing Opencode into VSCode by opening it up from the integrated terminal, but it didn't work. So, I manually installed the VSCode extension and tried to start OpenCode from that extension, but even then, when the CLI pops up, it has no connection to my ide/editor.

Plugins

No response

OpenCode version

1.125

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

on macos running vscode on my ubunutu linux box using vscode remote ssh plugin

Terminal

No response

Activity

  1. github-actions commented on Jan 18, 2026

    @github-actions
    Contributor

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

    Feel free to ignore if none of these address your specific case.

  2. LIHUA919 commented on Jan 18, 2026

    @LIHUA919

    The root cause of this issue is that in Remote SSH scenarios, the VSCode extension runs on your local macOS machine, but the CLI server runs on the remote Ubuntu machine.

    When the extension tries to connect via fetch(http://localhost:${port}/app`)` (line 78 in extension.ts), it connects to local localhost instead of the remote localhost where the CLI server is listening.

    Solution

    VSCode provides the vscode.env.asExternalUri() API to handle this exact scenario. It automatically sets up port forwarding for remote environments.

    For the OpenCode maintainers

    The fix requires modifying sdks/vscode/src/extension.ts:

    Current code (line 78):

    await fetch(`http://localhost:${port}/app`)

    Should be:

    const externalUri = await vscode.env.asExternalUri(
      vscode.Uri.parse(`http://localhost:${port}/app`)
    );
    await fetch(externalUri.toString());

    The same change is needed in the appendPrompt function (line 94).

    Workaround for users

    Until this is fixed, you can manually set up SSH port forwarding:

    1. Find the port displayed in the terminal (the random port number)
    2. Add SSH port forwarding in your SSH config or use:
      ssh -L ${port}:localhost:${port} your-server

    Reference: Supporting Remote Development and GitHub Codespaces - see the "Forwarding localhost" section

  3. github-actions commented on Mar 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 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

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions