Help Debugging SeleniumBase UC Mode Failure in Nixpacks Deployment (uc_driver not found)

Anonymous
FREE

4 months ago

Hi Railway/Nixpacks team! Need help getting SeleniumBase(uc=True) working in a Nixpacks deployment.

Goal: Headless Chromium logs into Google, gets cookies.
Problem:Driver(uc=True, headless=True) fails during init in Railway deployment. Base FastAPI app works fine.
Environment: Railway, Nixpacks (Python), python:3.9-slim base, seleniumbase, fastapi, uvicorn, supabase.

nixpacks.toml:

[phases.setup]
nixPkgs = ["chromium", "nss"]

(Dockerfile apt-get install chrome is commented out).

Status & What Fails:

  • SSH confirms Nix-installed chromium runs, network/permissions seem OK.

  • Error shifted after adding nss: Previously uc_driver exited (Status 127 - likely missing libs, friend saw [libnss3.so](libnss3.so) error). Now uc_driver file isn't found/saved in seleniumbase/drivers/ at all.

  • Crucially: Adding a larger list of potential libs (e.g., gtk+3, libX11) to nixPkgs caused the Nixpacks build itself to fail.

Questions:

  1. What's the correct way to include all required shared libraries for chromium & uc_driver via nixPkgs?

  2. Why might adding many common libs break the Nixpacks build? (Known conflicts/issues?)

  3. How best to debug the uc_driver startup failure within the Nixpacks runtime?

Using seleniumbase.Driver(uc=True, headless=True) in Python. Any pointers on the Nixpacks config for headless browsers would be great! Thanks!

Solved

0 Replies

Anonymous
FREE

4 months ago

c273ff49-d38d-48f7-afbe-925a93b75499


Anonymous
FREE

4 months ago

I've removed nss from nixpkgs for now - didnt see a reason to keep it


4 months ago

have you tried using Browserless instead? -


Anonymous
FREE

4 months ago

Did not know this was a thing, I'll try it today, will keep this thread updated


Anonymous
FREE

4 months ago

Now it doesnt work locally, as when i use browserless google detects that its a selenium based browser. The point of using selenium base with undetectable mode was so that i am able to sign into a google account. The old code still works locally, just fails to deploy due to missing libraries. Does browserless support seleniumbase?


Anonymous
FREE

4 months ago

Deployment to Render has succeeded. Still no luck on railway. Is there a way to just fix this missing libraries error? Its extremely specific to railway and the way railway initializes chromium/selenium. works like butter deploying locally, even works on render with a couple of minor adjustments


4 months ago

you could write a Dockerfile


Anonymous
FREE

4 months ago

thats exactly what im doing, works perfectly fine locally but fails to deploy on railway despite working fine locally

here's the current dockerfile:

# Base image with Python
FROM python:3.9-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1

# Install system dependencies
RUN apt-get update && apt-get install -y \
    wget \
    gnupg \
    unzip \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Install Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
    && apt-get update \
    && apt-get install -y google-chrome-stable \
    && rm -rf /var/lib/apt/lists/*

# Set up working directory
WORKDIR /app

# Install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip && \
    pip install -r requirements.txt && \
    pip install python-dotenv  # Add python-dotenv for .env support

# Copy application code and .env file
COPY . .
# No need to copy .env separately since it's already included in the previous COPY command

# Expose port
EXPOSE 8000

# Command to run the application
CMD ["python", "main.py"]

4 months ago

may i ask why nixpacks was mentioned then? nixpacks and dockerfiles are mutually exclusive


Anonymous
FREE

4 months ago

I'm not a super experienced dev, when i was facing this issue with docker i did a bunch of debugging with ai, it told me to use dockerfile for everything (except chromium) and add chromium only via nixpacks
do you suggest running locally with nixpacks? as local docker works fine and fails in deployment - and im assuming since railway uses nixpacks it'd be more productive to run what railway runs locally?


4 months ago

if you have a working dockerfile locally then using that on railway is going to be most productive.. does your dockerfile work locally?


Anonymous
FREE

4 months ago

Exactly what im thinking! Dockerfile works perfectly locally, sent it to a friend, and it worked like a charm on his machine as well! However deployment to railway shows drivers missing error


4 months ago

are you building with buildkit locally too?


Anonymous
FREE

4 months ago

Nope, locally its pure dockerfile


4 months ago

try with buildkit, since thats what we build with


Anonymous
FREE

4 months ago

Is buildkit enabled by default if i build using a dockerfile?


Anonymous
FREE

4 months ago

To resend the message i sent on general, since mods asked me to keep my questions contained to this thread:


Anonymous
FREE

4 months ago

What about caching? Suppose im building a custom docker image
Does the build get cached? The build time initially on my local machine is 2 minutes, and subsequent builds are <2s
Will the same be reflected on railway?
Or should i upload this to a public registry and pull from there


Anonymous
FREE

4 months ago

Thank you so much for the help so far, this has been incredibly helpful

I managed to get the server deployed - just need to optimise for build times now


4 months ago

awsome, im glad you solved it, but what was the issue if you dont mind me asking?


Anonymous
FREE

4 months ago

it was incredibly stupid, get this: i never realised railway wasnt using the dockerfile. after you mentioned the buildkit thing i figured out that you have to explicitly define the dockerfile path to use it to build
so sorry 😭


Anonymous
FREE

4 months ago

what about this?


4 months ago

Well that would do it, unless its named Dockerfile and at the root, then you would need to tell us what to use.


Anonymous
FREE

4 months ago

yeah it was at root but named dockerfile not Dockerfile, so ig thts why it didnt pick it up


4 months ago

if you are using a custom docker image, there is no build step.

do you perhaps mean custom dockerfile?


Anonymous
FREE

4 months ago

sorry yeah i meant custom dockerfile


4 months ago

then yes, layers are still cached, but your build could end up on a machine that doesn't have the cache and thus no cache will be used for that particular build since we don't yet have a global cache


Anonymous
FREE

4 months ago

So what's the best approach for minimising build times if the build ending up on a different machine is a possiblity? ghcr?


4 months ago

yeah you could build your image on ghcr, but it's really not worth it with what you lose imo


Anonymous
FREE

4 months ago

wait what do you lose if you push to ghcr? what do you recommend?


4 months ago

you lose the auto deploys on push, i recommend keep deploying from github as you have been


Anonymous
FREE

4 months ago

Oh cool got it, ig i can deal with 2min build times


4 months ago

sounds good!


4 months ago

good to mark this as solved?


Anonymous
FREE

4 months ago

yep. thanks a ton!


4 months ago

!s


Status changed to Solved brody 4 months ago


Help Debugging SeleniumBase UC Mode Failure in Nixpacks Deployment (uc_driver not found) - Railway Help Station