User Agents

Web browsers and everyday web tech, explained

Fix Playwright Install: Browsers, deps, CI, Docker

· 5 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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@latest or pip install playwright)
  • Admin/root access if installing system dependencies

Step-by-Step

  1. Verify your Playwright version. Run npx playwright --version (Node) or playwright --version (Python). If it fails, reinstall: npm install -D @playwright/test or pip install --upgrade playwright.
  2. Install browser binaries. Run npx playwright install (Node) or playwright install (Python). This downloads Chromium, Firefox, and WebKit to your user cache. If you only need one browser, use --with-deps or specify it, e.g., npx playwright install chromium.
  3. Install system dependencies (Linux). On Ubuntu/Debian, run npx playwright install-deps (Node) or sudo playwright install-deps (Python). This installs all required libraries. For other distros, see the official Playwright docs for the list.
  4. Check your proxy settings. If you're behind a corporate proxy, set environment variables before running installs: export HTTP_PROXY=http://proxy:port export HTTPS_PROXY=http://proxy:port export NO_PROXY=localhost,127.0.0.1 Then run the install command again.
  5. Fix certificate issues. If you get SSL errors, set NODE_TLS_REJECT_UNAUTHORIZED=0 (Node) or PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT=120000 as a temporary workaround, but prefer adding your corporate CA to the system trust store.
  6. 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 the mcr.microsoft.com/playwright:v1.40.0-focal image and run npx playwright install --with-deps in the before_script.
  7. 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 with docker build -t my-tests . and docker run my-tests.
  8. 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.
  9. Check for missing OS libraries manually. If install-deps fails, run ldd $(which chromium) to see missing libraries, then install them with your package manager.
  10. 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 install after updating Playwright — always reinstall browsers after upgrading.
  • Running install-deps without 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.json or requirements.txt to avoid unexpected breakage.
  • Use npx playwright install --dry-run to 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.