19 days ago
I have a monorepo, and my /server folder uses Playwright to make requests.
I’m trying to run Express.js endpoints that make requests via Playwright with a proxy. It works fine locally in Docker, but on Railway it fails because Playwright is missing dependencies.
I tried installing the missing dependencies in the Dockerfile, but it doesn’t help. Everything builds properly on Railway, but when a request runs, it fails.
I've seen the Playwright + Puppeteer Stealth template and was doing pretty much the same things, but I still get errors about missing dependencies.
Playwright request response:
browserType.launch: ╔══════════════════════════════════════════════════════╗║ Host system is missing dependencies to run browsers. ║║ Missing libraries: ║║ libglib-2.0.so.0 ║║ libgobject-2.0.so.0 ║║ libnspr4.so ║║ libnss3.so ║║ libnssutil3.so ║║ libdbus-1.so.3 ║║ libgio-2.0.so.0 ║║ libatk-1.0.so.0 ║║ libatk-bridge-2.0.so.0 ║║ libexpat.so.1 ║║ libatspi.so.0 ║║ libX11.so.6 ║║ libXcomposite.so.1 ║║ libXdamage.so.1 ║║ libXext.so.6 ║║ libXfixes.so.3 ║║ libXrandr.so.2 ║║ libgbm.so.1 ║║ libxcb.so.1 ║║ libxkbcommon.so.0 ║║ libasound.so.2 ║╚══════════════════════════════════════════════════════╝Dockerfile:
FROM mcr.microsoft.com/playwright:v1.50.0-noble
WORKDIR /app
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libglib2.0-0 \
libgobject-2.0-0 \
libnspr4 \
libnss3 \
libnssutil3 \
libdbus-1-3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libexpat1 \
libatspi0 \
libx11-6 \
libxcomposite1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libxcb1 \
libxkbcommon0 \
libasound2 \
libcairo2 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
fonts-liberation \
&& rm -rf /var/lib/apt/lists/*
COPY server/package*.json ./server/
COPY client/package*.json ./client/
COPY shared/package*.json ./shared/
ENV DATABASE_URL="postgres://fake:fake@localhost:5432/fake"
ENV NODE_ENV=production
RUN npm --prefix server ci
RUN npm --prefix client ci
RUN npm --prefix shared ci
COPY . .
RUN npm --prefix client run build
RUN npm --prefix server run build
RUN npm --prefix shared run build
EXPOSE 8080
CMD ["npm", "--prefix", "server", "run", "start"]2 Replies
19 days ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Nixpacks Monorepo: TypeScript Build Artifacts Not Preserved in Deployed Container
🧵 Running Playwright using Browserless-v2 template on Railway
If you find the answer from one of these, please let us know by solving the thread!
18 days ago
Hey — I’ve actually hit this exact issue before on Railway. The root of the problem is that Playwright needs a bunch of system libraries for Chromium, and even if everything works locally in Docker, Railway’s runtime doesn’t always ship with the same libs. So Playwright launches fine locally but then completely faceplants in the cloud.
Here are the two fixes that’ve consistently worked for me:
1. Use the Official Playwright Docker Image
Honestly the easiest win. Playwright publishes Docker images like:
```
mcr.microsoft.com/playwright:v1.56.1-noble
```
These come with all the browser binaries + system deps already baked in.
Switch your FROM line:
```dockerfile
FROM mcr.microsoft.com/playwright:v1.56.1-noble
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["npm", "run", "start"]
```
No dependency guessing, no missing-lib surprises. This fixes it almost every time.
2. Auto-Install Missing Deps with Playwright
If you want to stick with a custom base image, add:
```dockerfile
RUN npx playwright install-deps
```
That pulls in all required libraries (glib, atk, nspr, nss, x11 libs, etc.) automatically based on the OS and your Playwright version.
I usually place it right after:
```dockerfile
RUN npm ci
```
If your image doesn’t already include the browsers, add:
```dockerfile
RUN npx playwright install
```
After rebuilding and redeploying on Railway, the “missing dependencies” error should disappear and your Express routes using Playwright should finally work correctly.
If it still misbehaves, it’s probably a permissions or memory issue, but dependency-wise this setup is solid.
