google-chromeselenium-webdriverselenium-chromedrivergoogle-chrome-headlessundetected-chromedriver

Could not use undetected chrome Headless=True


I am using the following:

Trying to do web automation, when using headless False, everything works well, but when using headless True, I get :

"selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:18424 from chrome not reachable"

Any idea how to solve? Thanks!


Solution

  • You could try using https://github.com/seleniumbase/SeleniumBase in UC Mode.

    After pip install seleniumbase, run the following with python:

    from seleniumbase import Driver
    
    driver = Driver(uc=True, headless=True)
    driver.get("https://nowsecure.nl/#relax")
    driver.quit()
    

    SeleniumBase includes a fork of undetected-chromedriver with bug fixes.