puppeteer: [Bug]: Missing X server or $DISPLAY
Bug description
Steps to reproduce the problem:
I am running crawlsite.js function from puppeteer/examples/crawlsite.js path in their git repo and i am seeing the exact same issue - [186875:186875:0318/202225.133327:ERROR:ozone_platform_x11.cc(234)] Missing X server or $DISPLAY [186875:186875:0318/202225.133388:ERROR:env.cc(225)] The platform failed to initialize. Exiting.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md[](https://github.com/pankhiprasher)
at onClose (/root/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:237:20) at Interface.<anonymous> (/root/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:227:68) at Interface.emit (node:events:539:35) at Interface.close (node:internal/readline/interface:529:10) at Socket.onend (node:internal/readline/interface:258:10) at Socket.emit (node:events:539:35) at endReadableNT (node:internal/streams/readable:1342:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) I dont know why it works in headless true but as soon as i change it to headless false it doesnt launch chrome browser and gives this error. Can anyone please help?
Puppeteer version
13.5.2
Node.js version
17.0.0
npm version
8.5.2
What operating system are you seeing the problem on?
Linux
Relevant log output
I am running crawlsite.js function from puppeteer/examples/crawlsite.js path in their git repo and i am seeing the exact same issue -
[186875:186875:0318/202225.133327:ERROR:ozone_platform_x11.cc(234)] Missing X server or $DISPLAY
[186875:186875:0318/202225.133388:ERROR:env.cc(225)] The platform failed to initialize. Exiting.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/root/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:237:20)
at Interface.<anonymous> (/root/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:227:68)
at Interface.emit (node:events:539:35)
at Interface.close (node:internal/readline/interface:529:10)
at Socket.onend (node:internal/readline/interface:258:10)
at Socket.emit (node:events:539:35)
at endReadableNT (node:internal/streams/readable:1342:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
I dont know why it works in headless true but as soon as i change it to headless false it doesnt launch chrome browser and gives this error.
Can anyone please help?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 16
- Comments: 54
Still happening
I am on Ubuntu 22.04 and the chromium can launch in the rdp session via rdp terminal, or via remote ssh with
DISPLAY
set to:10.0
. But puppeteer gives the error nonetheless on both occasions. It seems it is launching the chrome/chromium in a different way.Later I noticed
env?: Record<string, string | undefined>;
so usingsolved my problem
We’re marking this issue as unconfirmed because it has not had recent activity and we weren’t able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.
Are you running this remotely or in a VM where there isn’t a display to view? This issue usually occurs when chromium is trying to launch a GUI but doesn’t have a display to hook into. In Linux, you can usually remediate this issue with software like
xvfb
.Development mode Install xvfb
apt-get install xvfb x11-apps x11-xkb-utils libx11-6 libx11-xcb1
Then run the following commandXvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99
this worked for me
Same here…got it working on my Windows machine … doesn’t work on Linux (Debian 10) Following…
I had same issue while using $code . in ubuntu 18.04.6 I having local machine problem not in remote server. I have solved by just changing DISPLAY variable in .bashrc Try this steps, 1.vim ~/.bashrc 2.edit using “i” 3.change value in line “export DISPLAY=$(some_value)” to “export DISPLAY=:0” 4.source ~/.bashrc
Hope this will help somebody.
@InanisV @jnalbert @vvolodin Solution for me which worked on Debian 11, first find the display variable with
printenv DISPLAY
on the terminal session which open on RDP or whatever, it was like that for me:then put that into your
crontab
code as,It works!
export XAUTHORITY=$HOME/.Xauthority && chromium-browser
Are you all running in
headless
mode on the VM?I got this error when I forgot to set:
puppeteer.launch({ headless: true })
@OrKoN I saw you closed both #8148 and 7743
Is there no explanation why this will not get fixed? it is obvious that many people run into this issue and the majority is not really able to solve it.
Would you be so kind and elaborate what we should do now?
THX!
@pankhiprasher I think you have to set headlees to true
const browser = await puppeteer.launch({ args: ['--no-sandbox'], headless: true, // !! true executablePath: '/usr/bin/chromium-browser', });
Can someone state definitively whether puppeteer is designed to be used on a machine that does not have any sort of display software (such as X) or display (AKA a headless machine)?
I’m having the same issue running on Ubuntu 20.04 in docker via xfvb, I have a $DISPLAY set.
I was able to partially resolve this issue using VcXsrv Windows X Server, and with the help of this guide, and this answer.
I say “partially” as the terminal is still throwing up a bunch of errors for files and tags not found. But as far as I can tell everything is working correctly i.e. now when I enter
google-chrome
into my WSL Ubuntu terminal, it launches and works just fine.Hope this helps 😃
(For reference, I’m running Ubuntu through WSL2 on Windows 11)
Had this issue on Ubuntu server 22.04 but on remote shell. I tried to launch browser with headless mode false (so would have a GUI) . But there is no $DISPLAY on remote shell.
So getting $DISPLAY value from host terminal and applied it to my puppeteer config.
Now running from my remote shell & it works fine ! thanks @rainb3rry @mkmark
how can i upvote this answer with recursion that have no limit?
@BioPhoton Unfortunately, it’s not something that can be fixed in Puppeteer. A headful browser requires an x server or a display: see for various solutions depending on a operating system/docker etc https://stackoverflow.com/questions/60304251/unable-to-open-x-display-when-trying-to-run-google-chrome-on-centos-rhel-7-5
The issue also affects a whole range of programs not just chrome: see https://www.baeldung.com/linux/no-x11-display-error
I’m here because of an unrelated framework giving me the exact same error. I’m running Ubuntu 18 in WSL on Windows 10.
This worked for me, I did it like crazy, xd I was already desperate and it worked
Install Xvfb if you didn’t install it yet and do the following steps.
sudo apt-get install -y xvfb
Dependencies to make “headless” chrome/selenium work:sudo apt-get -y install xorg xvfb gtk2-engines-pixbuf
sudo apt-get -y install dbus-x11 xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic xfonts-scalable
Optional but nifty: For capturing screenshots of Xvfb display:sudo apt-get -y install imagemagick x11-apps
Make sure that Xvfb starts every time the box/vm is booted:Xvfb -ac :99 -screen 0 1280x1024x16 &
export DISPLAY=:99
Run Google Chromegoogle-chrome
thanks worked, i’m running it on node.js using command
xvfb-run --auto-servernum node index.js
Encountered this today on WSL2 and the issue was that I had multiple instances of VcXsrv running. Closed them all, started from the top and hey presto <google-chrome> opened the browser. I followed this article to get set up initially: https://www.gregbrisebois.com/posts/chromedriver-in-wsl2/
Hope that might help someone