Skip to content
Latchkey

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.

Playwright
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 closed

Common 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

  1. Run npx playwright install --with-deps so all libraries are present.
  2. If the job runs as root in a container, launch with the no-sandbox arg.
  3. Re-run and read any remaining linker error for a still-missing library.
launch options
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.

.github/workflows/ci.yml
container:
  image: mcr.microsoft.com/playwright:v1.44.0-jammy

How to prevent it

  • Install browsers with --with-deps so no library is missing at launch.
  • Pass --no-sandbox only when running as root in a trusted CI container.
  • Prefer the official Playwright image to avoid environment drift.

Frequently asked questions

What causes ""browserType.launch: Failed to launch""?
The binary starts, the dynamic linker fails to resolve a .so, and the process dies before Playwright can attach.
How do I fix "browserType.launch: Failed to launch"?
Install dependencies, then relax the sandbox if root

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card