Error: Failed to launch the browser process! Unable to open X display.

See original GitHub issue

Bug description

I am on a Windows 11 machine, running Puppeteer from Ubuntu 20.4 (WSL 2.0)

This is the standard boilerplate code to run things:

async function ssr(url) {
  const browserHeadless = await puppeter.launch({ 
    headless: true,
  })

  const page = await browserHeadless.newPage()

  ...

Everything seems to work just fine when the optional param headless is set to true.

However, when I want to test things with headless: false, things go belly up.

I have literally scoured the net, Stack Overflow, GitHub, including puppeteer troubleshooting, this issue, this other issue and other articles read online.

Puppeteer version

10.4.0

Node.js version

16.13.0

npm version

8.1.0

What operating system are you seeing the problem on?

Windows

Relevant log output

reject(new Error([
                   ^
Error: Failed to launch the browser process!
[10270:10270:1103/133318.960840:ERROR:browser_main_loop.cc(1409)] Unable to open X display.

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20)
    at ChildProcess.<anonymous> (/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:188:79)
    at ChildProcess.emit (node:events:402:35)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
kommandercommented, Sep 8, 2022

We ran into a similar issue, running with docker compose locally:

pdf-1  | [1] /app/workspaces/apps/pdf/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:229
pdf-1  | [1]             reject(new Error([
pdf-1  | [1]                    ^
pdf-1  | [1] 
pdf-1  | [1] Error: Failed to launch the browser process!
pdf-1  | [1] Error: Can't open display: 
pdf-1  | [1] 
pdf-1  | [1] 
pdf-1  | [1] TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
pdf-1  | [1] 
pdf-1  | [1]     at onClose (/app/workspaces/apps/pdf/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:229:20)
pdf-1  | [1]     at Interface.<anonymous> (/app/workspaces/apps/pdf/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:219:68)
pdf-1  | [1]     at Interface.emit (node:events:539:35)
pdf-1  | [1]     at Interface.close (node:readline:586:8)
pdf-1  | [1]     at Socket.onend (node:readline:277:10)
pdf-1  | [1]     at Socket.emit (node:events:539:35)
pdf-1  | [1]     at endReadableNT (node:internal/streams/readable:1345:12)
pdf-1  | [1]     at processTicksAndRejections (node:internal/process/task_queues:83:21)

Using "puppeteer": "13.1.2",, with manually installed chromium on node:16.15.0-bullseye-slim.
Setting:

PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

Starting puppeteer like so:

this.browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox'] });

EDIT: When running chromium-browser --product-version I only get:

root@eb2379677dc0:/app# chromium --product-version
Error: Can't open display: 

EDIT 2: Same issue with newer versions of puppeteer

0reactions
OrKoNcommented, Nov 4, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Headful mode doesn't launch (Unable to open X display.) #5429
Headful mode doesn't launch (Unable to open X display.) #5429 ... Error: Failed to launch the browser process!
Read more >
node.js - Puppeteer | Unable to open X display | Ubuntu 20.04
I am just assuming that you are executing this on a terminal only Ubuntu? In my case it was the Ubuntu Windows subsystem...
Read more >
Puppeteer - Failed to launch the browser process! - DietPi
I've been trying all morning to solve this error and I can't find the solution. any ... Puppeteer - Failed to launch the...
Read more >
Troubleshooting - Puppeteer
UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! This means that the browser was downloaded but failed to be extracted correctly.
Read more >
puppeteer 在服务端报错:Unable to open X display - 码道人
报错信息:. (node:1) Error: Failed to launch the browser process! Fontconfig warning: "/etc/fonts/fonts.conf", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found