-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Message: unknown error: cannot connect to chrome at 127.0.0.1:50276 #743
Comments
I have been trying different things and the verbose driver logs seem to have changed a bit.
|
try to add incognito into your driver. options.add_argument("--incognito") |
Using incognito option didn't work. |
Any news? Same is happening to me. It is strangely working from PyCharm but when I start it from a crontab on Ubuntu it doesn’t work |
Nope, my work has come to a complete halt because of this. Cant find any solution. I have tried almost every trick posted on any related problems thread. |
I've noticed that whenever I use the parameter "--user-data-dir" at the driver options:
If I delete that "c:\WhateverFolder", it works again, but of course, I must re-login on every site. |
Do you solve this question? |
I had the same problem so I did the following: |
I have the same problem if I use
Does anyone knows how to fix this error? |
Heys Guys, I have the same problems. |
following |
Heys Guys, I have the same problems. |
try adding these arguments to the driver
|
Is there any update on this issue, i have tried to add arguments mentioned by @smsajjadzaidi but it still gives this error |
Faced the same problem, occurred using python 3.7. Solution was to update to python 3.8. |
Add this all: options.add_argument("--disable-extensions") And try to running in headless: Same as update to last version and use chrome driver manager instead of path or local variable If still not working then clean your linux and try again Edit: the 2 dumbs that put a 👎 are idiots that even didnt tested, |
I had the same issue when running uc inside a Python Docker container (based on
DEBIAN_FRONTEND=noninteractive && \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub > /usr/share/keyrings/chrome.pub && \
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/chrome.pub] http://dl.google.com/linux/chrome/deb/ stable main' > /etc/apt/sources.list.d/google-chrome.list && \
apt update -y && \
apt install -y google-chrome-stable
apt install xvfb -y
export DISPLAY=:1
Xvfb $DISPLAY -screen $DISPLAY 1280x1024x16 &
python3 example.py Here's the example script I used: import undetected_chromedriver as uc
from time import sleep
log_path = "/chromedriver.log"
url = "https://check.torproject.org/"
chrome_driver = uc.Chrome(service_log_path=log_path)
chrome_driver.get(url)
sleep(5)
scraped_page = chrome_driver.page_source
chrome_driver.quit()
print(scraped_page) Note that I'm running the driver without the All of it is a truncated version of this Docker image (requires login to Docker hub) by @ultrafunkamsterdam. I know that the original question was not about running uc inside a Docker container, but I hope it could give you some ideas. |
Thanks martroben So can easy to run Chrome driver in container
|
@michaeloo0 i tried your image and it throws me any ideas ? |
yes,in this image the version of chrome is 108, so please using follow script to recreate docker image
|
Just like @Habidis said, deleting the profile folder works for me. |
Found a solution for the problem. If you are using the DIR folder that currently has a browser profile open. it will not work. you have to close everything first and then run it. That was the workaround for it for me. |
Thank you @Anticope12 your solution worked. Just need to close other instances of Chrome before running script !! I've been frustrated the last couple weeks as my scripts were hanging with the following error message: selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:57930 Tried all the different arguments, but nothing worked. Now working again, just need to close browser first! |
@phl0yd , @Anticope12 hi, Can you share your code here, please? Although I closed the Chrome app in the background, it didn't work on my end. |
@asimptot Not sure if all these options are necessary, but this is the code I am currently running. Before you change your code, you may want to open task manager and make sure every Chrome task is shut down. import undetected_chromedriver as uc undetected_chromedriveroptions = uc.ChromeOptions() #added new options since issues in Jan 2023 #743 driver = uc.Chrome(use_subprocess=True,options = options) with driver: ...... |
Here is my code and that worked for me!
|
Clearing of the user profile folder worked for me. As same as incognito mode. But i need history, cookies, etc. between sessions.
|
@s-o-f yes you are correct about that. But deleting it means not being able to reuse the custom profile sadly. |
Looking at all of the above solutions, my reason should be the addition of --user-data-dir, and there is something wrong(don't know exactly why) with the userdata folder. I tried all of the add_argument methods above, and none of them worked. (windows) |
Try this:
|
RHEL8, google-chrome-stable build 114.0.5735.90, python3.9, uc 3.4.7, chromedriver 114.0.5735.16 My options are minimal at the following ....
Xvfb stuff is not needed for me. chromedriver seems to be very sensitive to /tmp. Check your |
Tried all but nothing |
|
I think it's some file broken in the profile dir, in my case, I compared the profile dir with another working one, then found there is a file named "Preferences" took 2.3GB, I deleted the file and Chrome can start now |
Yes!Yes, it works! Love You! |
how could we find this file? Could you give some details, please? |
Hi, in my case, delete ProfileDir\Default\Preferences file fixed the issue |
I was running multiple instances of UC. Besides using some of the fixes mentioned above, adding some wait time before launching each instance also helped. |
Thank you. It works!!!!!👏 |
Could not find the ProfileDir folder. What am I missing here? 😑 |
|
2023 ends --user-data-dir= still not working |
Having the same issue with a test script I wrote:
a bunch of the options are there because I've found they've been needed in the past on regular chrome |
as of today with chrome 119 and latest 3.5.4 undetected_chromedriver, i got same problem when trying to launch chrome with options.add_argument('--user-data-dir=/path/to/my/profile') and i could see 3 Singleton*** files in the root of my profile : SingletonLock, SingletonSocket,SingletonCookie. these being symlinks, and even broken symlinks. removing them and restarting with my default options, i could reuse as expected. |
Ha! Related to #1362 and some threads I've found on Stackoverflow. After running the same profile dir over time. Py.exe process eats the RAM from 2-5GB because of this file "Preferences". |
@s-o-f great solution, this fixed my code... I was trying to create headless which was failing due to this but in non headless it was working. I was facing this issue in linux |
https://github.com/anilabhadatta/educative.io_scraper/blob/v3-master/src/Utility/BrowserUtility.py |
for those who are running headful Chrome on a server, check that you have #!/bin/bash
function keepUpScreen()
{
echo "running keepUpScreen()"
while true; do
sleep 1
if [ -z "$(pidof -x Xvfb)" ]; then
Xvfb $DISPLAY -screen $DISPLAY 1920x1080x16 &
fi
done
}
export DISPLAY=:1
rm -f /tmp/.X1-lock &>/dev/null
keepUpScreen &
echo "running: $@"
exec $@ So I've created an entrypoint with this, and that solved my issue. |
This is not documented anywhere, but I've recently found that if you don't call This seems to have fixed the issue for me. |
thank you so much, this worked for me. make sure that you check your task manager/windows tray to see if chrome is running in the background, which was my case |
Hey,
I am running a script on a headless server via ssh. The script was working fine until about a week ago. I made some minor unrelated changes, post which undetected-chromedriver started failing.
I am attaching a very simplified code below.
I get the following stdout/stderr
The complete stack trace is
Driver verbose logs.
Operating System: Ubuntu 16.04.7 LTS
Kernel: Linux 4.4.0-210-generic
Architecture: x86-64
$ chrome --version
Google Chrome 103.0.5060.134 unknown
$ which chrome
/opt/google/chrome/chrome
$ python --version
Python 3.7.7
undetected-chromedriver==3.1.5.post4
If I simply try to run selenium headless, I am facing no problems.
Any help would be appreciated.
Thanks.
The text was updated successfully, but these errors were encountered: