Playwright "error while loading shared libraries: libnss3.so" in CI
The Chromium binary exists and starts, but ld.so cannot resolve libnss3.so because the package providing it (libnss3) is not installed. This is the single most common missing library on minimal Debian/Ubuntu images.
What this error means
A launch fails with "browserType.launch: ... error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory", often the only missing library on an otherwise working image.
browserType.launch: Target page, context or browser has been closed
Browser logs:
<launching> .../headless_shell ... error while loading shared libraries:
libnss3.so: cannot open shared object file: No such file or directoryCommon causes
libnss3 not installed in the container
Chromium dynamically links Network Security Services; a minimal image omits libnss3, so the loader cannot start the browser.
Only some Playwright dependencies were installed
A hand-picked apt list missed libnss3, whereas playwright install-deps would have included it.
How to fix it
Let Playwright install the full dependency set
Run install-deps (or install --with-deps) so every required library, including libnss3, is present.
npx playwright install-deps chromiumInstall the package directly if you manage apt yourself
When you control the Dockerfile, add libnss3 explicitly alongside the other browser libraries.
apt-get update && apt-get install -y \
libnss3 libatk-bridge2.0-0 libgbm1 libasound2How to prevent it
- Prefer
playwright install-depsover a manual apt allowlist. - Build a custom image once with all browser libraries baked in.
- Test the image by launching a browser in a smoke step before the full suite.