Skip to content
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

UC was able to work before, and got now Cannot connect to chrome at 127.0.0.1:{port changed everytime} from chrome not reachable #670

Closed
lancezhaozai opened this issue Jun 9, 2022 · 3 comments

Comments

@lancezhaozai
Copy link

lancezhaozai commented Jun 9, 2022

Traceback (most recent call last):
File "/home/user/PycharmProjects/S3/testnike.py", line 21, in
driver = uc.Chrome(options=chrome_options)
File "/home/user/PycharmProjects/S3/venv/lib/python3.9/site-packages/undetected_chromedriver/init.py", line 401, in init
super(Chrome, self).init(
File "/home/user/PycharmProjects/S3/venv/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in init
super(WebDriver, self).init(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/user/PycharmProjects/S3/venv/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in init
RemoteWebDriver.init(
File "/home/user/PycharmProjects/S3/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 275, in init
self.start_session(capabilities, browser_profile)
File "/home/user/PycharmProjects/S3/venv/lib/python3.9/site-packages/undetected_chromedriver/init.py", line 589, in start_session
super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
File "/home/user/PycharmProjects/S3/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 365, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/user/PycharmProjects/S3/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 430, in execute
self.error_handler.check_response(response)
File "/home/user/PycharmProjects/S3/venv/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, 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:48855
from chrome not reachable

the code:

import undetected_chromedriver as uc
import time

chrome_options = uc.ChromeOptions()
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument('--user-data-dir=/home/user/.config/google-chrome')
chrome_options.add_argument("--profile-directory=Profile 3")

driver = uc.Chrome(options=chrome_options)

time.sleep(60)

driver.close()

From chrome://version:
Chrome version: 102.0.5005.61 (Official Build) (64-bit)
Executable Path | /opt/google/chrome/google-chrome
Profile Path | /home/user/.config/google-chrome/Default

undetected-chromedriver==3.1.5.post4

Problem:
last night the code was fine, everything work, I able to launch UC directly from python and get pass CF and akamai.
but today I restarted my workstation, and have above errors

Scenario 1. UC unable to work totally and shows "Chrome is being controlled by automated test software", and got the above errors

Scenario 2. I launch chrome manually, then launching UC in code, the chrome windows pop without "Chrome is being controlled by automated test software" and works by clicking and input data MANUALLY, but still got above errors

Scenario 3. I change the --user-data-dir=/home/user/.config/google-chrome to --user-data-dir=/home/user/.config/google-chrome/Default, now it cannot get pass CF and akamai

I tried other threads and stackoverflow possible fix in order to overcome this issue but no luck, so I believe yesterday I just got lucky and got pass chrome session and connected it, it seems has something to do with the chrome session like

#155

but I cannot find the root cause and get it solve

Edit 1:
I had tried old version of chrome and old version of UC, it got even more errors like "The directory is being used", so i decided to step back to last worked code

@lancezhaozai lancezhaozai changed the title UC was able to work before UC was able to work before, and got now Cannot connect to chrome at 127.0.0.1:{port changed everytime} from chrome not reachable Jun 9, 2022
@ultrafunkamsterdam
Copy link
Owner

remove your manual options especially profile directory. make sure nothing chrome related is running, so pkill -f google-chome

@lancezhaozai
Copy link
Author

remove your manual options especially profile directory. make sure nothing chrome related is running, so pkill -f google-chome

I had removed profile directory and make sure nothing chrome related is alive in system, I had done what you mentioned and yes it did resolved the errors, but wont work for bypassing Akamai and CF, last night I was able to connect to the opened chrome session that I manually launch, and UC able to bypass Akamai and CF perfectly, with profile directory, because profile directory intend to reuse the opened chrome session and connect to it, it works that way last night, but right now it got the error I mentioned

Do you mind I send you everything to reproduce the error and idea? because with UC connected to chrome session, it really works

@ultrafunkamsterdam
Copy link
Owner

ultrafunkamsterdam commented Jun 9, 2022

that is in fact what uc does. launching chrome and manually connects to it. it's quite simple here: chrome does not start and therefore uc cannot connect . you need to find out what command line is used by uc (debug=True) then copy it to a terminal and see the output.

oh: you can run only 1 instance per userdatadir .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants