browser-use: real_browser.py Example Doesn’t Work Properly
I’m trying to run the real_browser.py example from the browser-use library, but I’m encountering issues. Here’s what’s happening:
- When I run the code, I get the following error in the terminal:
ERROR [browser] Failed to start a new Chrome instance.: BrowserType.connect_over_cdp: connect ECONNREFUSED 127.0.0.1:9222
Call log:
- <ws preparing> retrieving websocket url from http://localhost:9222
The error repeats multiple times during execution, despite ensuring that all Chrome instances are fully closed before running the script.
- After the code finishes, it opens 6 Chrome windows unexpectedly.
Here’s the full log from my terminal:
INFO [browser_use] BrowserUse logging setup complete with level info
INFO [root] Anonymized telemetry enabled. See https://github.com/browser-use/browser-use for more information.
INFO [agent] 🚀 Starting task: In docs.google.com write my Papa a quick thank you for everything letter
- Magnus and save the document as pdf
INFO [agent]
📍 Step 1
ERROR [browser] Failed to start a new Chrome instance.: BrowserType.connect_over_cdp: connect ECONNREFUSED 127.0.0.1:9222
Call log:
- <ws preparing> retrieving websocket url from http://localhost:9222
WARNING [browser] Page load failed, continuing...
ERROR [browser] Failed to start a new Chrome instance.: BrowserType.connect_over_cdp: connect ECONNREFUSED 127.0.0.1:9222
Call log:
- <ws preparing> retrieving websocket url from http://localhost:9222
ERROR [agent] ❌ Result failed 1/3 times:
To start chrome in Debug mode, you need to close all existing Chrome instances and try again otherwise we can not connect to the instance.
...
I checked that all Chrome instances are closed before running the script. It seems like that the code works fasted then browser.
How can I make the real_browser.py example work properly with my Chrome instance?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 9
- Comments: 29 (3 by maintainers)
One issue here should be fixed now https://github.com/browser-use/browser-use/pull/1232! There was a bug where the
BrowserConfigwas being completely ignored.Make sure to quit all Chrome instances (cleanly) before starting browser-use. Otherwise it launch a 2nd browser which may step on the toes of any existing running browsers if they share the same
user_data_dirand try to both writeSingletonLockfiles. We are also adding builtin support for launching with persistent user-data-dirs soon, stay tuned: https://github.com/browser-use/browser-use/pull/1218I still cannot fix it. I reinstalled Chrome, but it doesn’t help. It looks like the developer mode is too slow, and the first window opens after the code has already executed through 3 errors.