[Bug] Browser agent fails with 502 Bad Gateway when system proxy (e.g. Clash) is enabled on macOS

Environment

  • OS: macOS Sequoia 15.x (Apple Silicon)
  • Antigravity version: latest
  • Chrome version: 146.0.7680.81
  • System proxy: enabled (HTTP/HTTPS/SOCKS proxy on localhost, via Clash Verge)

Bug Description

When macOS system proxy is enabled, the browser agent fails to start with:

failed to connect to browser via CDP even though the CDP port is responsive:
http://127.0.0.1:9222: playwright: Unexpected status 502 when connecting to
http://127.0.0.1:9222/json/version/.
This does not look like a DevTools server, try connecting via ws://.

Root Cause Analysis

Playwright internally uses Node.js http module to fetch
http://127.0.0.1:9222/json/version/ to retrieve the WebSocket debugger URL.
Node.js inherits the macOS system proxy settings but ignores the
ExceptionsList (which correctly includes 127.0.0.1 and localhost).
As a result, the request is forwarded to the proxy server, which returns 502.

Verified:

  • curl http://127.0.0.1:9222/json/version/ returns 200 OK correctly
  • scutil --proxy confirms 127.0.0.1 is in ExceptionsList
  • No proxy env variables set ($http_proxy, $HTTP_PROXY etc. are all empty)
  • TUN exclusion rules also configured (127.0.0.0/8, ::1/128)
  • Issue is reproducible and consistent

Expected Behavior

The CDP connection to 127.0.0.1:9222 should bypass the system proxy,
as it is a loopback address.

Suggested Fix

Set NO_PROXY / GLOBAL_AGENT_NO_PROXY for loopback addresses before
Playwright initiates the CDP HTTP handshake. Alternatively, use the
ws:// endpoint directly from a pre-fetched webSocketDebuggerUrl
to skip the HTTP step entirely.

Reference

Related Playwright issue: [Bug]:playwright.connectOverCDP can't connect to the browser via a proxy · Issue #35206 · microsoft/playwright · GitHub

1 Like