Skip to content

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:9222 #2314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iamumairayub opened this issue Nov 24, 2023 · 1 comment
Labels
duplicate The answer/solution already exists somewhere external Outside SeleniumBase's scope. / Ask somewhere else. UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode

Comments

@iamumairayub
Copy link

I have had SB (SeleniumBase) working pretty well with UC mode (without any virtualdisplay/xvfb) and I was getting an error "You are using a Chromium-based browser" when testing with https://pixelscan.net

So I decided to run command sudo snap remove chromium and then I started getting error

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:9222

Here is my most basic code, it works well with uc=False but it is not what I want.

options = Options()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = Driver(
    uc=True,
    headless=True,
    cap_string=options.to_capabilities(),
)
driver.uc_open_with_reconnect("https://pixelscan.net/", reconnect_time=10)

Tried commenting our cap_string
Tried sudo snap install chromium
Tried uninstalling and installing undetected_chromedriver again
Tried uninstalling and installing seleniumbase again

I saw an issue on SB issues and also on https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues but those solutions/workarounds did not help.

Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal

google-chrome --version
Google Chrome 119.0.6045.159

Python 3.10.7

seleniumbase.version
'4.21.4'
@mdmintz mdmintz added duplicate The answer/solution already exists somewhere UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode external Outside SeleniumBase's scope. / Ask somewhere else. labels Nov 24, 2023
@mdmintz
Copy link
Member

mdmintz commented Nov 24, 2023

Duplicate of #2030 (comment)


Or if you need to use the Driver() format, then use https://github.com/mdmintz/sbVirtualDisplay for Xvfb activation:

from sbvirtualdisplay import Display
from seleniumbase import Driver

display = Display(visible=0, size=(1440, 1880))
display.start()

driver = Driver(uc=True, headless=True)
driver.uc_open_with_reconnect("https://pixelscan.net/", reconnect_time=10)
# ...
driver.quit()

display.stop()

@mdmintz mdmintz closed this as completed Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate The answer/solution already exists somewhere external Outside SeleniumBase's scope. / Ask somewhere else. UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode
Projects
None yet
Development

No branches or pull requests

2 participants