puppeteer: Headful mode doesn't launch (Unable to open X display.)
"version": "2.1.1"
Distributor ID: Debian
Description: Debian GNU/Linux 9.11 (stretch)
Release: 9.11
Codename: stretch
$ node -v
v12.14.1
Steps to reproduce
$ mkdir test && cd test && npm install puppeteer
> puppeteer@2.1.1 install /home/dun/_workspace/test/node_modules/puppeteer
> node install.js
Downloading Chromium r722234 - 121.1 Mb [====================] 100% 0.0s
Chromium downloaded to /home/dun/_workspace/test/node_modules/puppeteer/.local-chromium/linux-722234
npm WARN saveError ENOENT: no such file or directory, open '/home/dun/_workspace/test/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/dun/_workspace/test/package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.
+ puppeteer@2.1.1
added 43 packages from 24 contributors and audited 51 packages in 13.217s
1 package is looking for funding
run `npm fund` for details
found 0 vulnerabilities
$ touch test.js && echo "const puppeteer = require('puppeteer');
>
> (async () => {
> const browser = await puppeteer.launch({
> headless: false,
> args: ['--no-sandbox']
> });
> })();" >> test.js
$ node test.js
(node:24628) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank"
[24639:24639:0219/092954.631392:ERROR:browser_main_loop.cc(1512)] Unable to open X display.
[0219/092954.642321:ERROR:nacl_helper_linux.cc(308)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
at onClose (/home/dun/_workspace/test/node_modules/puppeteer/lib/Launcher.js:750:14)
at Interface.<anonymous> (/home/dun/_workspace/test/node_modules/puppeteer/lib/Launcher.js:739:50)
at Interface.emit (events.js:228:7)
at Interface.close (readline.js:402:8)
at Socket.onend (readline.js:180:10)
at Socket.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:24628) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:24628) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
What is the expected result? Puppeteer should launch in headful mode.
What happens instead? Puppeteer throws error and exits.
I ran $ sudo apt install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 l ibgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 li bx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libx ss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils
and restarded my server but it didn’t help.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 15
- Comments: 34
Commits related to this issue
- Fixed like this https://github.com/puppeteer/puppeteer/issues/5429 — committed to MrDonaldoWorking/Anime-site by MrDonaldoPublic 2 years ago
@dundunn Set headless to true 😃
That would be counterproductive if I wanted to start puppeteer in headful mode wouldn’t it?
I’ve spent countless days searching the internet on a solution for this. Everyone with this issue (including me) is probably using Windows and possibly WSL2. Issue is a compatibility issue with WSL2. Not sure how to fix as I still have the issue.
Edit: Solution seems to be to setup an X Display like vcXsrv so that the linux subsystem (WSL2) has a monitor to display on. But making it work with WSL2 is still not clear as many tutorials online are based on WSL1. I tried many tutorials to setup vcXsrv with latest WSL2 but couldn’t get it to work. Alternatively, you can try running your script using a windows based terminal instead of wsl2.
+1 to https://github.com/puppeteer/puppeteer/issues/5429#issuecomment-633785854, seems to be a compatibility issue with WSL. Switching from running the code on the WSL to Windows Powershell solved it for me.
@kevin8988
Can’t believe I spent an hour on this :XD
what is the status on this one? EDIT: I also have the “Unable to open X display” problem. I am using Xubuntu 18 (Desktop version with display and stuff) but still get this error. Puppeteer version 3.1.0
my solution was to allow xhost from remote with the command “xhost +” before puppeteer ececution
On Wed, 30 Jun 2021, 18:46 Juveria Manzar, @.***> wrote:
Same issue here, I am not able to solve it
I set up a piece of code, so it won’t work:
env: { TZ: 'Europe/London', },
Normal operation after removal.
export $DISPLAY
Chrome launch options need to set as below.
args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-extensions-except=' + this.extensionPathBuildPath, '--load-extension=' + this.extensionPathBuildPath ]
Got it working following those steps with vcXsrv Windows X Server:
You will likely be asked if you want to allow VcXsrv to access your network, you will have to click on the ‘Public network’ option and allow it through Windows Firewall or whatever firewall you use.
Now, I think this is the most important instruction I found in Stackoverflow, in the best answer section:
So, the only configuration I had to do in this moment, was setting my local Windows IP with
route.exe print
. To do it, edit your./bashrc
adding these two lines:After that, try running your Puppeteer script to see if it works. This was the only solution I found in two days, hope it helps someone else.
Best regards, Marcelo
maven users!
I added below dependencies in pom.xml
and removed below in my webdriver setup file:
options.setHeadless(true); options.setAcceptInsecureCerts(true);
but, I passed these arguments as below then, options.addArguments(“–headless”);
This above error (Unable to open X display) was gone! However, I have new error as “NoClassDefFoundError: org/openqa/selenium/virtualauthenticator/HasVirtualAuthenticator”. Good luck!