Playwright "browserType.launch: Failed to launch" in CI
Playwright spawned the browser process but it exited before the remote-debugging pipe was ready. The trailing "Target page, context or browser has been closed" or a linker error names the real cause: a missing library or a sandbox failure under root.
What this error means
Tests fail with "browserType.launch: Failed to launch" followed by process output that may include an "error while loading shared libraries" line or a sandbox message. It reproduces on every run once the environment is wrong.
browserType.launch: Failed to launch the browser process!
[pid=214] chrome: error while loading shared libraries: libgbm.so.1:
cannot open shared object file: No such file or directory
Target page, context or browser has been closedCommon causes
A missing shared library at launch
The binary starts, the dynamic linker fails to resolve a .so, and the process dies before Playwright can attach.
The sandbox cannot initialize in the container
Running as root or without the required kernel namespaces makes Chromium's sandbox fail, killing the process at startup.
How to fix it
Install dependencies, then relax the sandbox if root
- Run
npx playwright install --with-depsso all libraries are present. - If the job runs as root in a container, launch with the no-sandbox arg.
- Re-run and read any remaining linker error for a still-missing library.
const browser = await chromium.launch({
args: ['--no-sandbox', '--disable-dev-shm-usage'],
});Use the official Playwright container image
The maintained image bundles the browsers and OS libraries so launch works out of the box.
container:
image: mcr.microsoft.com/playwright:v1.44.0-jammyHow to prevent it
- Install browsers with
--with-depsso no library is missing at launch. - Pass
--no-sandboxonly when running as root in a trusted CI container. - Prefer the official Playwright image to avoid environment drift.