Deployment Failing: Chrome Non-Headless Mode Requires Xvfb Setup on Railway

turizmazdevsFREE

a month ago

I’m deploying a Python app that uses Botasaurus (a browser scrapping automation library) to parse a website requiring Chrome in non-headless mode (headless=False). The app works locally with Docker (Windows 11 + Docker Desktop), but deployment on Railway fails with a Chrome connection error. Despite configuring Xvfb to emulate a display, ChromeDriver cannot connect to Chrome during runtime.

Error Messages and Logs:

Error Traceback (Deploy Logs):

Traceback (most recent call last):

File "/opt/venv/lib/python3.12/site-packages/botasaurus_driver/core/retry_on_error.py", line 22, in wrapper

created_result = func(*args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^

File "/opt/venv/lib/python3.12/site-packages/botasaurus_driver/core/browser.py", line 374, in run

self.info = ensure_chrome_is_alive(chrome_url)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/venv/lib/python3.12/site-packages/botasaurus_driver/core/browser.py", line 59, in ensure_chrome_is_alive

raise Exception(f"Failed to connect to Chrome URL: {url}.")

Exception: Failed to connect to Chrome URL: http://127.0.0.1:54411/json/version.

Key Observations:

  • Botasaurus/ChromeDriver cannot connect to Chrome’s debugger URL (127.0.0.1:54411).

  • The error suggests Chrome isn’t running or isn’t accessible in the container.

Relevant Code and Configuration:

FROM selenium/standalone-chrome:latest # Base image includes Chrome

USER root

WORKDIR /app

RUN apt-get update && apt-get install -y xvfb # Explicit Xvfb installation

COPY requirements.txt main.py /app/

RUN pip install --no-cache-dir -r requirements.txt

COPY . /app

ENV HEADLESS=False

CMD ["xvfb-run", "-a", "--server-args=-screen 0 1920x1080x24 -ac", "python", "main.py"]

Botasaurus Configuration (Python Code):

@browser(

remove_default_browser_check_argument=True,

add_arguments=[

"--no-sandbox",

"--disable-setuid-sandbox",

"--disable-gpu",

"--disable-dev-shm-usage"

]

)

def scrape_visa(driver: Driver, data) -> None:

# ... Botasaurus logic ...

Questions for Railway Community/Support:

  1. Does Railway support Xvfb for GUI-dependent apps like Botasaurus/Chrome?

  2. Are there known issues with the selenium/standalone-chrome base image on Railway?

  3. Should I use a different base image (e.g., python:3.9-slim + manual Chrome/Xvfb install) instead?

Request for Guidance:

Any advice on configuring Botasaurus/Chrome with Xvfb on Railway would be greatly appreciated!

Closed

0 Replies

Status changed to Closed echohack about 1 month ago