Skip to content

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

fix:windows connect browser error

vincenteffb74232655
diff --git a/browser_use/browser/browser.py b/browser_use/browser/browser.py
index 15dbe76a2..5d887796e 100644
--- a/browser_use/browser/browser.py
+++ b/browser_use/browser/browser.py
@@ -151,6 +151,16 @@ class Browser:
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
+
+ # Attempt to connect again after starting a new instance
+ for _ in range(10):
+ try:
+ response = requests.get('http://localhost:9222/json/version', timeout=2)
+ if response.status_code == 200:
+ break
+ except requests.ConnectionError:
+ pass
+ await asyncio.sleep(1)
# Attempt to connect again after starting a new instance
try: