Skip to content

fix(mcp): bind extension relay to IPv4 loopback for WSL2#41209

Closed
DakshUbhadia wants to merge 1 commit into
microsoft:mainfrom
DakshUbhadia:fix-mcp-wsl2-relay
Closed

fix(mcp): bind extension relay to IPv4 loopback for WSL2#41209
DakshUbhadia wants to merge 1 commit into
microsoft:mainfrom
DakshUbhadia:fix-mcp-wsl2-relay

Conversation

@DakshUbhadia

Copy link
Copy Markdown

Description

Fixes #41180

The Problem:
When launching a Windows browser (like Microsoft Edge) via PLAYWRIGHT_MCP_EXECUTABLE_PATH from a WSL2 environment, the Playwright Extension relay fails to establish a connection and times out.

By default, Node's startHttpServer without a specified host binds to :: (IPv6), resulting in a generated extension URL containing ws://[::1]:<port>. WSL2 does not automatically forward Windows IPv6 localhost traffic into the Linux container, breaking the connection.

The Fix:

  1. Explicitly initialized the MCP relay httpServer with host: '127.0.0.1' in extensionContextFactory.ts.
  2. Added normalization in CDPRelayServer constructor to map ::1 to 127.0.0.1 so the generated mcpRelayUrl query parameter strictly uses an IPv4 address, which WSL2 successfully forwards from Windows.

Testing:

  • Verified the fix locally; the extension successfully connects to the relay across the WSL/Windows boundary.
  • Ran local MCP and Extension test suites.

Node.js defaults to the IPv6 loopback ([::1]) on WSL2, which Windows Edge
cannot reach due to WSL2 networking limitations.

This patch ensures the relay is reachable across the OS boundary by:
- Passing { host: '127.0.0.1' } to startHttpServer in extensionContextFactory.ts
- Normalizing '::1' to '127.0.0.1' in cdpRelay.ts as a defense-in-depth guard

Fixes microsoft#41180
@DakshUbhadia

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@yury-s

yury-s commented Jun 9, 2026

Copy link
Copy Markdown
Member

This is just a hack to force ipv4, I don't think we want force ipv4.

@yury-s yury-s closed this Jun 9, 2026
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.

[Bug]: WSL extension relay emits IPv6 loopback URL unreachable from Windows Edge

2 participants