Skip to content

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

Merge main into fix/issue-4050-windows-proxy and resolve conflicts

Laith Weinberger9932f0650009
diff --cc browser_use/browser/session.py
index 81e8e6a33,7a7a3b8ca..a311696e2
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@@ -1524,11 -1707,9 +1707,13 @@@ class BrowserSession(BaseModel)
)
# Run a tiny HTTP client to query for the WebSocket URL from the /json/version endpoint
+ # Default httpx timeout is 5s which can race the global wait_for(connect(), 15s).
+ # Use 30s as a safety net for direct connect() callers; the wait_for is the real deadline.
- async with httpx.AsyncClient(timeout=httpx.Timeout(30.0)) as client:
+ # For localhost/127.0.0.1, disable trust_env to prevent proxy env vars (HTTP_PROXY, HTTPS_PROXY)
+ # from routing local requests through a proxy, which causes 502 errors on Windows.
+ # Remote CDP URLs should still respect proxy settings.
+ is_localhost = parsed_url.hostname in ('localhost', '127.0.0.1', '::1')
- async with httpx.AsyncClient(trust_env=not is_localhost) as client:
++ async with httpx.AsyncClient(timeout=httpx.Timeout(30.0), trust_env=not is_localhost) 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)}')