Skip to content

Access chrome while in WSL environment #131

Closed
Closed

Description

@ljmerza

Is your feature request related to a problem? Please describe.

Codex works far better in a linux based environment thus it's generally recommended if yo are on windows to use WSL. The problem here is this MCP only tries to look for chrome inside the WSL instead of the host system.

Describe the solution you'd like

The MCP server would know it's in WSL and use the host system's chrome

Describe alternatives you've considered

Can use codex for windows but it's not officially supported.

Additional context
Add any other context or screenshots about the feature request here.

Activity

  1. yuwenlong commented on Sep 25, 2025

    @yuwenlong

    @OrKoN @jackfranklin It is indeed necessary to consider supporting the windows subsystem.

    Image
  2. OrKoN commented on Sep 25, 2025

    @OrKoN
    Collaborator

    @ljmerza Could you try to use the --executable-path argument in the MCP server config to pass a custom path to where Chrome is installed?

  3. yuwenlong commented on Sep 25, 2025

    @yuwenlong

    @OrKoN I just tried it and it didn't work. The wsl subsystem is Ubuntu. If I configure it with this parameter, it's equivalent to using windows chrome across systems. Does the code logic support it? You need to look at the code.

    Image Image
  4. OrKoN commented on Sep 25, 2025

    @OrKoN
    Collaborator

    Thanks for checking! I would have expected the ability to run Windows binaries to be a feature of the WSL :) In this case a few other options are possible:

    1. Starting Chrome manually with --remote-debugging-port=9222 and a custom --user-data-dir outside of WSL and connecting to the running Chrome by specifying --browser-url=http://127.0.0.1:9222 in the args for the MCP server.
    2. Installing a Linux Chrome version in WSL (https://support.google.com/chrome/a/answer/9025903?hl=en).
    3. Installing a Chrome for Testing build in WSL and pointing to it via --executable-path. npx @puppeteer/browsers install chrome@stable would install the latest stable build.

    We will look into WSL support in general but in code we are just launching sub-processes (and we cannot do much if the environment does not support it) and locating Chrome at the well-known path per OS reported by Node.

  5. OrKoN commented on Sep 25, 2025

    @OrKoN
    Collaborator

    @yuwenlong also Chrome is not started in the MCP discovery phase (it is started on the first tool call). The error could be something else. Which gemini-cli version do you use and which node version is it?

  6. ThomasRumasLM commented on Sep 25, 2025

    @ThomasRumasLM

    Hello, I'm also trying to use the MCP through a DevContainer, can be the same solution for WSL and DevContainer I guess.

    I already tried to launch a Chrome instance by using the --browserUrl=http://host.docker.internal:9222, but I got a connection refused that my header isn't an IP with a curl.

    So I tried the solution with Puppeteer installation, I give the executable path to the MCP with this configuration:

    "chrome-devtools": {
        "type": "stdio",
        "command": "npx",
        "args": [
            "chrome-devtools-mcp@latest",
            "--executable-path=/workspaces/xxx/chrome/linux_arm-140.0.7339.207/chrome-linux64/chrome",
            "--headless",
            "--isolated",
            "--no-sandbox"
            // "--browserUrl=http://host.docker.internal:9222"
        ]
    }

    When I'm not using the isolated parameter, I got this error:

    Image

    When I'm using it, I've got now:

    Image

    When I'm checking the output of the MCP Server, I don't see any errors :

    2025-09-25 08:49:35.039 [info] Discovered 26 tools
    2025-09-25 08:50:23.874 [info] Stopping server chrome-devtools
    2025-09-25 08:50:23.910 [info] Connection state: Stopped
    2025-09-25 08:50:27.460 [info] Starting server chrome-devtools
    2025-09-25 08:50:27.461 [info] Connection state: Starting
    2025-09-25 08:50:27.467 [info] Starting server from Remote extension host
    2025-09-25 08:50:27.493 [info] Connection state: Starting
    2025-09-25 08:50:27.494 [info] Connection state: Running
    2025-09-25 08:50:28.231 [warning] [server stderr] chrome-devtools-mcp exposes content of the browser instance to the MCP clients allowing them to inspect,
    2025-09-25 08:50:28.231 [warning] [server stderr] debug, and modify any data in the browser or DevTools.
    2025-09-25 08:50:28.231 [warning] [server stderr] Avoid sharing sensitive or personal information that you do want to share with MCP clients.
    2025-09-25 08:50:28.244 [info] Discovered 26 tools

    Let me know If I need to open an other issue specifically for DevContainer

  7. OrKoN commented on Sep 25, 2025

    @OrKoN
    Collaborator

    If you use containers you should also have required system dependencies installed to run Chrome in the container https://pptr.dev/guides/system-requirements

  8. yuwenlong commented on Sep 25, 2025

    @yuwenlong

    @yuwenlong also Chrome is not started in the MCP discovery phase (it is started on the first tool call). The error could be something else. Which gemini-cli version do you use and which node version is it?

    Image
  9. ThomasRumasLM commented on Sep 25, 2025

    @ThomasRumasLM

    If you use containers you should also have required system dependencies installed to run Chrome in the container https://pptr.dev/guides/system-requirements

    I've already installed the needed package but still got the Protocol error (Target.setDiscoverTargets): Target closed

  10. yuwenlong commented on Sep 25, 2025

    @yuwenlong

    感谢您的检查。Node 20 不受支持(请参阅https://github.com/ChromeDevTools/chrome-devtools-mcp?tab=readme-ov-file#requirements)。

    @OrKoN Thank you. node has been upgraded.

    Image Image

    It seems to be okay. The mcp configuration is as follows. Let others who have encountered problems take a look:

    "chrome-devtools": {
                            "command": "npx",
                            "args": [
                                    "-y",
                                    "chrome-devtools-mcp@latest",
                                    "--executable-path=/mnt/c/Program\\ Files/Google/Chrome/Application/chrome.exe"
                            ]
                    }
  11. yuwenlong commented on Sep 25, 2025

    @yuwenlong

    @OrKoN I'm still not sure if it can work in actual operation? After all, this is an exe run by ubuntu on windows. It should still not work. After all, it's cross-system!

  12. OrKoN commented on Sep 25, 2025

    @OrKoN
    Collaborator

    @yuwenlong please see other possible options in #131 (comment)

  13. yuwenlong commented on Sep 25, 2025

    @yuwenlong

    @yuwenlong please see other possible options in #131 (comment)

    Ok. Thank you.

  14. 37 remaining items

  15. hsearcy commented on Jan 21, 2026

    @hsearcy

    This worked for me in cursor-agent after cussing it out several times until it suggested the DISPLAY=:0 env setting:

    "chrome-devtools": {
          "command": "npx",
          "args": [
            "chrome-devtools-mcp@latest",
            "--executablePath=/usr/bin/google-chrome"
          ],
          "env": { "DISPLAY": ":0" }
        }
    
  16. clshortfuse commented on Feb 11, 2026

    @clshortfuse

    WSL2 has a lot of issues with GPU support enabled and networking. Went with this

    # Needs
    # "C:\Program Files\Google\Chrome\Application\chrome.exe" --user-data-dir="%TEMP%/chrome-mcp" --remote-debugging-port=9222 --remote-debugging-address=127.0.0.1 --no-first-run --no-default-browser-check
    [mcp_servers.chrome-devtools]
    command = "npx"
    args = ["chrome-devtools-mcp@latest", "--browserUrl=http://localhost:9222"]

    At worst I have to run the command in Windows first, and then Codex can pick it up. Not sure what the exact CLI to replicate the Windows MCP setup is, but it works.

  17. reopened this on Feb 12, 2026
  18. self-assigned this
    on Feb 12, 2026
  19. OrKoN commented on Feb 12, 2026

    @OrKoN
    Collaborator

    The root cause of this is that WSL drops file descriptors 3 & 4 when a subprocess is launched which weird because Windows itself supports it and Linux supports it as well, the issue is in the WSL interoperability layer somewhere. Current workarounds:

    • running Chrome with --remote-debugging-port on the Windows host (note that it is accessible to other programs on your host) and the MCP server with --browser-url on the Linux side.
    • running npx on the Windows side via cmd.exe.
  20. OrKoN commented on Feb 12, 2026

    @OrKoN
    Collaborator

    Reported the issue to WSL microsoft/WSL#14201. Will see if we can fallback on the websocket for WSL.

  21. CybotTM commented on Feb 17, 2026

    @CybotTM

    Using the chrome dev MCP with chrome inside WSL works for me now:

    https://www.reddit.com/r/ClaudeCode/comments/1q43hxe/chrome_dev_tools_mcp_from_wsl_windows/ made it work for me:

    just ask your coding agent to fix the MCP:

    Chrome DevTools MCP from WSL - Setup Guide

    Problem

    Chrome DevTools MCP wasn't working at all from WSL — Target closed errors on every tool call.

    Root Cause

    The default config (--headless only) couldn't launch Chrome in WSL because Chrome requires --no-sandbox in WSL environments (no kernel sandbox support).

    Fix

    MCP config in ~/.claude.json:

    "chrome-devtools": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "chrome-devtools-mcp@latest",
        "--headless",
        "--chromeArg", "--no-sandbox"
      ],
      "env": {}
    }

    Key: --chromeArg and --no-sandbox must be separate args in the array (not --chromeArg=--no-sandbox).

    Bonus: ddev SSL support

    By default, headless Chrome rejects ddev's self-signed certificates (ERR_CERT_AUTHORITY_INVALID). Instead of --ignore-certificate-errors (which didn't work via --chromeArg), install the mkcert CA into Chrome's NSS trust store:

    # One-time setup (requires: apt install libnss3-tools)
    certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n "mkcert-ca" -i "$(mkcert -CAROOT)/rootCA.pem"

    Prerequisites

    • Google Chrome in WSL: apt install google-chrome-stable
    • For ddev sites: libnss3-tools package for certutil
  22. OrKoN commented on Feb 25, 2026

    @OrKoN
    Collaborator

    So WSL is not going to support the additional pipes (see microsoft/WSL#14201). I have documented workarounds here https://github.com/ChromeDevTools/chrome-devtools-mcp/blob/main/docs/troubleshooting.md#wsl basically either Chrome needs to be installed within WSL as per requirements or WSL needs to be configured with mirrored networking to access the Chrome instance on the Windows side over WebSockets.

  23. rtabulov commented on May 26, 2026

    @rtabulov

    this works for me

    {
      "mcpServers": {
        "chrome-devtools": {
          "command": "/mnt/c/Users/rassul/AppData/Local/mise/shims/npx.exe",
          "args": ["-y", "chrome-devtools-mcp@latest"],
          "env": {}
        }
      }
    }

    ps you should probably change the command path because i'm using mise...
    just try to run which npx.exe from wsl

  24. zdayang commented on May 27, 2026

    @zdayang

    For anyone landing here from Codex/Claude in WSL, the maintainer workaround above is the important split: do not try to make WSL launch or discover the Windows Chrome profile through local Linux paths. Treat Windows Chrome as an already-running remote debugging endpoint.

    The repeatable setup I would use is:

    1. Start Windows Chrome yourself with a fixed port and a dedicated non-default profile.
    2. From WSL, verify the endpoint before changing MCP config:
    curl http://127.0.0.1:9222/json/version
    1. Point chrome-devtools-mcp at that URL with --browser-url http://127.0.0.1:9222.
    2. Fully restart Codex/Claude so the MCP server list reloads.

    The dedicated profile matters because newer Chrome remote-debugging behavior is stricter around the default profile, and it also keeps AI-driven browser sessions separate from your everyday Chrome profile.

    I wrote up the WSL-specific checklist here:
    https://github.com/zdayang/wsl-chrome-bridge-support

    Disclosure: that repo supports a small paid package I sell, but the checklist and failure-mode notes are public and can be followed manually.

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

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions