Skip to content
Latchkey

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.

playwright
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 directory

Common 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.

Terminal
npx playwright install-deps chromium

Install the package directly if you manage apt yourself

When you control the Dockerfile, add libnss3 explicitly alongside the other browser libraries.

Dockerfile
apt-get update && apt-get install -y \
  libnss3 libatk-bridge2.0-0 libgbm1 libasound2

How to prevent it

  • Prefer playwright install-deps over 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.

Frequently asked questions

What causes ""libnss3.so: cannot open shared object file""?
Chromium dynamically links Network Security Services; a minimal image omits libnss3, so the loader cannot start the browser.
How do I fix "libnss3.so: cannot open shared object file"?
Run install-deps (or install --with-deps) so every required library, including libnss3, is present.

Related guides

References

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