'Cannot connect to chrome at 127.0.0.1:53007 while using undetected_chromedriver in Python
I am trying to use undetected_chromedriver for bypassing Cloudfare Protection.
This is the simple code I am trying to use
import undetected_chromedriver as uc
from selenium import webdriver
import time
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
driver = uc.Chrome(options=options)
url = 'https://etherscan.io/tx/0x6b0e974952c7df4270cfb4aac332042af9b72c487e42d0bc04a676134118c1ac'
driver.get(url)
time.sleep(5)
print(driver.title)
However, I get the error :
Traceback (most recent call last):
File "test2.py", line 9, in <module>
driver = uc.Chrome(options=options)
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/undetected_chromedriver/__init__.py", line 401, in __init__
super(Chrome, self).__init__(
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 269, in __init__
self.start_session(capabilities, browser_profile)
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/undetected_chromedriver/__init__.py", line 589, in start_session
super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 360, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/root/tx_sniper/my_env/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 425, in execute
self.error_handler.check_response(response)
File "/root/tx_sniper/my_env/lib/python3.8/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:58911
from chrome not reachable
Stacktrace:
#0 0x5622d155aad3 <unknown>
#1 0x5622d12ba3ff <unknown>
#2 0x5622d12a8ab9 <unknown>
#3 0x5622d12e0f69 <unknown>
#4 0x5622d12d8ee6 <unknown>
#5 0x5622d13142ba <unknown>
#6 0x5622d130e4e3 <unknown>
#7 0x5622d12e3d1a <unknown>
#8 0x5622d12e4e75 <unknown>
#9 0x5622d1588efd <unknown>
#10 0x5622d15a219b <unknown>
#11 0x5622d158ac65 <unknown>
#12 0x5622d15a2ec8 <unknown>
#13 0x5622d157e360 <unknown>
#14 0x5622d15bea68 <unknown>
#15 0x5622d15bebe8 <unknown>
#16 0x5622d15d87fd <unknown>
#17 0x7f129a6566db <unknown>
I am using the following versions :
Python 3.8
Google Chrome : 100.0.4896.75
ChromeDriver : 100.0.4896.60
undetected-chromedriver : 3.1.5.post4
selenium : 4.1.3
Solution 1:[1]
Usually I use chrome's default userdata-dir, for example: /home/vncuser/.config/google-chrome
I met the same problem sometimes, what I need to do just delete the preference file in the userdata-dir:
rm ~/.config/google-chrome/Default/Preferences
If the 'Preferences' file is too large(1~3 GB), the chrome will crash. The normal size of that file would be only a few KBs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Chikong Ho |