Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix: disable proxy for localhost CDP requests (#4050)

Chase Xu2bd5211eb073
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index 56ac6cae1..be465753e 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -1524,7 +1524,9 @@ class BrowserSession(BaseModel):
)
# Run a tiny HTTP client to query for the WebSocket URL from the /json/version endpoint
- async with httpx.AsyncClient() as client:
+ # Use trust_env=False to prevent proxy env vars (HTTP_PROXY, HTTPS_PROXY) from
+ # routing localhost requests through a proxy, which causes 502 errors on Windows
+ async with httpx.AsyncClient(trust_env=False) as client:
headers = self.browser_profile.headers or {}
version_info = await client.get(url, headers=headers)
self.logger.debug(f'Raw version info: {str(version_info)}')