I’ve been reading and testing about how to get Chrome (via Selenium) working on Render and I’m just about ready to quit. I don’t know much about Docker, so I’ve been avoiding it, but the work around is failing. I’m on the paid starter plan.
At first, I had issues getting the Driver installed, but quickly found the shell script that was posted. This then led to issues with DevTools ActivePort file doesn’t exist, but some add_arguments
(the port one) fixed that. Yet, no matter what I do I cannot get selenium to run.
One thing to note, I read all the posts I could find on here about it and I decided to switched from the shell script to the pip package as it’s a lot cleaner. In both cases, the errors are the same.
Here’s my console log:
Jun 26 10:55:21 PM ==> Starting service with 'uvicorn main:app --host 0.0.0.0 --port 10000'
Jun 26 10:55:28 PM INFO: Started server process [51]
Jun 26 10:55:28 PM INFO: Waiting for application startup.
Jun 26 10:55:28 PM INFO: Application startup complete.
Jun 26 10:55:28 PM INFO: Uvicorn running on http://0.0.0.0:10000 (Press CTRL+C to quit)
Jun 26 10:55:38 PM Your service is live 🎉
Jun 26 10:55:39 PM INFO: 34.82.247.67:0 - "GET / HTTP/1.1" 404 Not Found
Jun 26 10:56:32 PM 2023-06-27 02:56:32,274 loglevel=INFO logger=endpoints.saving post_save_item() L47 post to /save_url for 'https://www.instagram.com/reel/CslboyRN041/?igshid=MTc4MmM1YmI2Ng=='
Jun 26 10:56:32 PM
Jun 26 10:56:32 PM 2023-06-27 02:56:32,694 loglevel=INFO logger=WDM log() L11 ====== WebDriver manager ======
Jun 26 10:56:32 PM 2023-06-27 02:56:32,841 loglevel=INFO logger=WDM log() L11 There is no [linux64] chromedriver "latest" for browser google-chrome "None" in cache
Jun 26 10:56:32 PM 2023-06-27 02:56:32,939 loglevel=INFO logger=WDM log() L11 Get LATEST chromedriver version for google-chrome
Jun 26 10:56:33 PM 2023-06-27 02:56:33,074 loglevel=INFO logger=WDM log() L11 About to download new driver from https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip
Jun 26 10:56:33 PM
[WDM] - Downloading: 0%| | 0.00/7.06M [00:00<?, ?B/s]
[WDM] - Downloading: 8%|▊ | 552k/7.06M [00:00<00:01, 5.64MB/s]
[WDM] - Downloading: 100%|██████████| 7.06M/7.06M [00:00<00:00, 38.8MB/s]
Jun 26 10:56:33 PM 2023-06-27 02:56:33,635 loglevel=INFO logger=WDM log() L11 Driver has been saved in cache [/opt/render/.wdm/drivers/chromedriver/linux64/114.0.5735.90]
Jun 26 10:56:35 PM Traceback (most recent call last):
Jun 26 10:56:35 PM File "/opt/render/project/src/services/extract_link.py", line 105, in get_link_soup
Jun 26 10:56:35 PM driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options)
Jun 26 10:56:35 PM File "/opt/render/project/src/.venv/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 49, in __init__
Jun 26 10:56:35 PM super().__init__(
Jun 26 10:56:35 PM File "/opt/render/project/src/.venv/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 54, in __init__
Jun 26 10:56:35 PM super().__init__(
Jun 26 10:56:35 PM File "/opt/render/project/src/.venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 206, in __init__
Jun 26 10:56:35 PM self.start_session(capabilities)
Jun 26 10:56:35 PM File "/opt/render/project/src/.venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 291, in start_session
Jun 26 10:56:35 PM response = self.execute(Command.NEW_SESSION, caps)["value"]
Jun 26 10:56:35 PM File "/opt/render/project/src/.venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 346, in execute
Jun 26 10:56:35 PM self.error_handler.check_response(response)
Jun 26 10:56:35 PM File "/opt/render/project/src/.venv/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
Jun 26 10:56:35 PM raise exception_class(message, screen, stacktrace)
Jun 26 10:56:35 PM selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
Jun 26 10:56:35 PM (chrome not reachable)
Jun 26 10:56:35 PM (The process started from chrome location /opt/render/.wdm/drivers/chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Jun 26 10:56:35 PM Stacktrace:
Jun 26 10:56:35 PM #0 0x563c0482f4e3 <unknown>
Jun 26 10:56:35 PM #1 0x563c0455ec76 <unknown>
[...]
Jun 26 10:56:35 PM #15 0x563c04818847 <unknown>
Jun 26 10:56:35 PM #16 0x563c04828243 <unknown>
Jun 26 10:56:35 PM #17 0x7fbbecae6fa3 start_thread
Jun 26 10:56:35 PM
Jun 26 10:56:35 PM 2023-06-27 02:56:35,187 loglevel=ERROR logger=services.extract_link get_link_soup() L128 Error downloading content from URL: https://www.instagram.com/reel/CslboyRN041/?igshid=MTc4MmM1YmI2Ng==
Jun 26 10:56:35 PM Error message: Message: unknown error: Chrome failed to start: exited abnormally.
Jun 26 10:56:35 PM (chrome not reachable)
Jun 26 10:56:35 PM (The process started from chrome location /opt/render/.wdm/drivers/chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Jun 26 10:56:35 PM Stacktrace:
Jun 26 10:56:35 PM #0 0x563c0482f4e3 <unknown>
Jun 26 10:56:35 PM #1 0x563c0455ec76 <unknown>
[...]
Jun 26 10:56:35 PM #15 0x563c04818847 <unknown>
Jun 26 10:56:35 PM #16 0x563c04828243 <unknown>
Jun 26 10:56:35 PM #17 0x7fbbecae6fa3 start_thread
Jun 26 10:56:35 PM
Jun 26 10:56:35 PM 2023-06-27 02:56:35,188 loglevel=ERROR logger=endpoints.saving post_save_item() L100 Error downloading content from URL: https://www.instagram.com/reel/CslboyRN041/?igshid=MTc4MmM1YmI2Ng==
Jun 26 10:56:35 PM INFO: 52.15.118.168:0 - "POST /save_url HTTP/1.1" 404 Not Found
And here is the related python code:
try:
# Set up the Selenium WebDriver
options = webdriver.ChromeOptions()
if ENV_NAME == 'production':
options.binary_location = "/opt/render/.wdm/drivers/chromedriver"
options.add_argument('--verbose')
options.add_argument('--no-sandbox')
options.add_argument('--headless')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--remote-debugging-port=9222')
options.add_argument('--disable-extensions')
options.add_argument('--disable-gpu')
options.add_argument('--user-agent={}'.format(random.choice(list(self.user_agents))))
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options)
driver.set_page_load_timeout(90)
# Load the URL and get the page source
driver.get(url)
time.sleep(4) # let load
html = driver.page_source
I’m not sure if there’s something simple I am missing, but I hope someone can help! Cheers.
(And thank you for all the other related threads on this).