Skip to content

feat: add WSL2 support for accessing Windows host Chrome#36

Open
xjdrew wants to merge 2 commits into
pasky:mainfrom
xjdrew:feat/wsl2-windows-chrome-support
Open

feat: add WSL2 support for accessing Windows host Chrome#36
xjdrew wants to merge 2 commits into
pasky:mainfrom
xjdrew:feat/wsl2-windows-chrome-support

Conversation

@xjdrew

@xjdrew xjdrew commented Mar 31, 2026

Copy link
Copy Markdown

This PR adds detection and connection support for Chrome running on Windows host when the CLI is executed from within WSL2 Linux environment.

Changes

  • Detect WSL environment by checking /proc/version for 'microsoft' or 'wsl'
  • Resolve Windows LocalAppData path via cmd.exe (prefers %LOCALAPPDATA%, falls back to %USERPROFILE%\AppData\Local) and convert via wslpath
  • Search for DevToolsActivePort in Windows Chrome profiles from WSL

Use Case

Users running the CLI in WSL2 can now control Chrome instances running on the Windows host without additional configuration. This is common for developers who:

  • Run their development environment in WSL2
  • Have Chrome installed on Windows (not in WSL)
  • Want to use this CLI from their WSL terminal

Testing

Tested on WSL2 Ubuntu 24.04 with Chrome running on Windows 11:

$ scripts/cdp.mjs list
6BE827FA  Page Title  https://example.com

The CLI now automatically detects the Windows Chrome DevTools port and connects via the WSL2 host gateway IP.

xjdrew added 2 commits March 31, 2026 16:04
Add detection and connection support for Chrome running on Windows host
when the CLI is executed from within WSL2 Linux environment.

Changes:
- Detect WSL environment by checking /proc/version
- Resolve Windows LocalAppData path via cmd.exe and wslpath
- Search for DevToolsActivePort in Windows Chrome profiles from WSL
- Use Windows host IP (from /etc/resolv.conf nameserver) when connecting
to Windows Chrome from WSL

This allows users running the CLI in WSL2 to control Chrome instances
running on the Windows host without additional configuration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant