undetected-chromedriver icon indicating copy to clipboard operation
undetected-chromedriver copied to clipboard

can't run same user_data_dir again

Open Jiroun opened this issue 1 year ago • 9 comments

the problem is first time I run the program with user_data_dir

options = uc.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')

driver =uc.Chrome(options = options, user_data_dir="/root/Aladdin")

then I do my stuff like login or something

if I run the program again to same folder ( but this time shoud be already logged in to my website)

this problem appear

driver =uc.Chrome(options = options, user_data_dir="/root/Aladdin") File "/usr/local/lib/python3.10/dist-packages/undetected_chromedriver/__init__.py", line 443, in __init__ super(Chrome, self).__init__( File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chrome/webdriver.py", line 49, in __init__ super().__init__( File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/chromium/webdriver.py", line 54, in __init__ super().__init__( File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 206, in __init__ self.start_session(capabilities) File "/usr/local/lib/python3.10/dist-packages/undetected_chromedriver/__init__.py", line 674, in start_session super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session( File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 291, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 346, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:58797 from chrome not reachable

forget to mention _ problem happen on linux only , on windows works fine

Jiroun avatar Jul 01 '23 19:07 Jiroun

Same here, maybe is a port issues on Linux.

rafamelo01 avatar Jul 07 '23 00:07 rafamelo01

Same here, maybe is a port issues on Linux.

yes , for me I just moved to windows

Jiroun avatar Jul 07 '23 01:07 Jiroun

I have the same problem with a Linux docker container and natively on macOS. I only experience this issue when running in headless mode. Has anyone found a workaround or solution?

23ari avatar Jul 24 '23 15:07 23ari

I think this problem may be related to the version of chrome, these days I have been using uc on windows, everything was fine a few days ago, now I have the same problem, the only change is that my chrome automatically updated to version 115.

chjtwork avatar Jul 25 '23 18:07 chjtwork

In windows it is updated automatically and with that the problem is solved, is that it? Already in linux, chrome is not updated automatically and from there the problems begin to arise, do you think this is the error?

rafamelo01 avatar Jul 26 '23 13:07 rafamelo01

I have the same problem, i use UC on Ubuntu. The solution i found is that everytime i open UC, i create a random folder, and then tell UC to use it.

basedir2=Path( __file__ ).parent.absolute().joinpath(str(''.join(random.choices(string.ascii_lowercase, k=7))))
try:
    os.mkdir(basedir2)
except:
    pass
options = uc.ChromeOptions()
driver = uc.Chrome(user_data_dir=basedir2,options=options)

momo286 avatar Aug 09 '23 08:08 momo286

The problem is the SingletonLock file. I submitted a PR for a fix here #1505 . Also be aware that if you use the substring 'headless' in your profile path, things will break. I submitted another PR #1506 to at least drop a warning about this but the logic for removing args that contain 'headless' should be updated.

mcoliver avatar Aug 24 '23 17:08 mcoliver

I have the same issue on #1670

joeld1 avatar Nov 20 '23 18:11 joeld1

get the same issue on centos docker

lynnwho12 avatar Feb 16 '24 10:02 lynnwho12