Fix Playwright Install: Browsers, deps, CI, Docker
In this article
This guide walks you through fixing common Playwright installation problems: missing browser binaries, system dependencies, proxy issues, and failures in CI or Docker. By the end, you'll have a working Playwright setup in any environment.
What You'll Need
- A terminal (Command Prompt, PowerShell, or bash)
- Node.js (v16 or later) or Python (3.8+) depending on your language
- Playwright installed via npm or pip (if not, run
npm init playwright@latestorpip install playwright) - Admin/root access if installing system dependencies
Step-by-Step
- Verify your Playwright version. Run
npx playwright --version(Node) orplaywright --version(Python). If it fails, reinstall:npm install -D @playwright/testorpip install --upgrade playwright. - Install browser binaries. Run
npx playwright install(Node) orplaywright install(Python). This downloads Chromium, Firefox, and WebKit to your user cache. If you only need one browser, use--with-depsor specify it, e.g.,npx playwright install chromium. - Install system dependencies (Linux). On Ubuntu/Debian, run
npx playwright install-deps(Node) orsudo playwright install-deps(Python). This installs all required libraries. For other distros, see the official Playwright docs for the list. - Check your proxy settings. If you're behind a corporate proxy, set environment variables before running installs:
export HTTP_PROXY=http://proxy:portexport HTTPS_PROXY=http://proxy:portexport NO_PROXY=localhost,127.0.0.1Then run the install command again. - Fix certificate issues. If you get SSL errors, set
NODE_TLS_REJECT_UNAUTHORIZED=0(Node) orPLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT=120000as a temporary workaround, but prefer adding your corporate CA to the system trust store. - For CI (GitHub Actions, GitLab CI, etc.). Use the official Playwright Docker image or action. For GitHub Actions, add this to your workflow:
steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 - run: npm ci - run: npx playwright install --with-deps - run: npx playwright test
For GitLab CI, use themcr.microsoft.com/playwright:v1.40.0-focalimage and runnpx playwright install --with-depsin the before_script. - For Docker. Create a Dockerfile based on the official Playwright image:
FROM mcr.microsoft.com/playwright:v1.40.0-focal WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npx playwright install --with-deps CMD ["npx", "playwright", "test"]
Build and run withdocker build -t my-tests .anddocker run my-tests. - Clear cache if browsers are corrupted. Delete the browser cache folder: on Linux/macOS
~/.cache/ms-playwright, on Windows%USERPROFILE%\AppData\Local\ms-playwright. Then reinstall. - Check for missing OS libraries manually. If
install-depsfails, runldd $(which chromium)to see missing libraries, then install them with your package manager. - Run a test to verify. Create a simple test file and run it. If it opens a browser, installation is successful.
Common Mistakes
- Forgetting to run
playwright installafter updating Playwright — always reinstall browsers after upgrading. - Running
install-depswithout sudo — it needs root to install packages. - Using the wrong Node version — Playwright requires Node 16+; older versions cause cryptic errors.
- In CI, not caching browsers — this makes builds slow but not broken; still, use caching to speed up.
- In Docker, not using the official image — custom images often miss libraries.
- Ignoring proxy variables — corporate networks need them set.
Tips
- Always pin your Playwright version in
package.jsonorrequirements.txtto avoid unexpected breakage. - Use
npx playwright install --dry-runto see what would be installed without actually downloading. - In CI, cache the browser cache directory (e.g.,
~/.cache/ms-playwright) to speed up subsequent runs. - For Docker, use multi-stage builds to keep the final image small.
- If you only need one browser, install just that to save time and disk space.
Troubleshooting
Error: "Executable doesn't exist" — This means browsers aren't installed. Run npx playwright install and ensure the path is correct. If you set PLAYWRIGHT_BROWSERS_PATH, make sure it points to the right location.
Error: "Host system is missing dependencies" — Run npx playwright install-deps as root. If it fails, manually install the missing libraries listed in the error message.
Error: "Timeout" or "Connection refused" during download — Likely a proxy issue. Set the proxy environment variables and retry. Also check your firewall.
Error: "Certificate verify failed" — Add your corporate CA to the system trust store, or temporarily set NODE_TLS_REJECT_UNAUTHORIZED=0 for testing.
Error: "Cannot find module 'playwright'" — Reinstall the package: npm install -D @playwright/test or pip install playwright.
Error: "Browser closed unexpectedly" — Check system resources (memory, CPU). In Docker, ensure you have enough shared memory: add --shm-size=1gb to your docker run command.
Error: "Permission denied" — On Linux, browsers may need executable permissions. Run chmod +x ~/.cache/ms-playwright/*/chrome-linux/chrome or reinstall.
Frequently Asked Questions
Why does Playwright install browsers but still fail to launch?
Usually missing system dependencies. Run npx playwright install-deps (Linux) or ensure all required libraries are present. Also check that the browser cache is not corrupted.
Can I use Playwright without downloading browsers?
Yes, you can use channel: 'chrome' or channel: 'msedge' to use your system-installed browser instead of Playwright's bundled ones. But you must have that browser installed.
How do I set a custom browser download path?
Set the environment variable PLAYWRIGHT_BROWSERS_PATH to your desired directory before running playwright install. For example: export PLAYWRIGHT_BROWSERS_PATH=/opt/pw-browsers.
Why does Playwright install fail in Docker with "libnss3" errors?
Your base image lacks required libraries. Use the official Playwright Docker image (mcr.microsoft.com/playwright) which includes all dependencies. Or run npx playwright install-deps inside your Dockerfile.
Can I install Playwright browsers offline?
Yes, download the browser zip files from the Playwright CDN (using a machine with internet) and place them in the cache directory. Then set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 during npm install and manually extract.
Why does Playwright work locally but not in CI?
CI environments often lack system dependencies and may have stricter network restrictions. Use the official CI actions/images and run npx playwright install --with-deps in your CI script.