-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Missing X server or $DISPLAY #8148
Comments
Same here...got it working on my Windows machine ... doesn't work on Linux (Debian 10) |
@kzenman i tried doing that directly onmy windows but i keep getting a lot of error on my windows terminal when i try installing some missing modules required for functions by doing npm install del . how do we fix that and then go over running node example.js command properly? Thanks |
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 |
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. |
I am Having similar issue vagrant@ubuntu-xenial: vagrant@ubuntu-xenial: |
Same issue here [3036:3036:0715/115626.763202:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY |
I'm here because of an unrelated framework giving me the exact same error. I'm running Ubuntu 18 in WSL on Windows 10. |
Check this out, this "Missing X server on $DISPLAY" was added back in 2018 |
The $DISPLAY is an environment variable that should be set if there is an X display ? That is what I got so far. Maybe figuring out what to set it to is the answer. |
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 Hope this helps :) (For reference, I'm running Ubuntu through WSL2 on Windows 11) |
I'm having the same issue running on Ubuntu 20.04 in docker via xfvb, I have a $DISPLAY set.
|
I have the same problem as @vvolodin trying to run xfvb in docker and i set the DISPLAY but it still threw an error |
@InanisV @jnalbert @vvolodin
then put that into your
It works! |
I am on Ubuntu 22.04 and the chromium can launch in the rdp session via rdp terminal, or via remote ssh with Later I noticed puppeteer.launch(
...,
env: {
...,
DISPLAY: ":10.0"
}
) solved my problem |
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)? |
have you tried by |
Same here with this Dockerfile : The error :
The dockerFile : FROM node:16-slim
# Update package informations, install wget and gnupg
RUN apt-get update \
&& yes | DEBIAN_FRONTEND=noninteractive apt-get install ca-certificates dbus-x11 fonts-liberation gconf-service gtk2-engines-pixbuf libappindicator1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release xorg xdg-utils xvfb \
&& apt-get install -y wget gnupg\
&& rm -rf /var/lib/apt/lists/*
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# If running Docker >= 1.13.0 use docker run's --init arg to reap zombie processes, otherwise
# uncomment the following lines to have `dumb-init` as PID 1
# ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
# RUN chmod +x /usr/local/bin/dumb-init
# ENTRYPOINT ["dumb-init", "--"]
# Uncomment to skip the chromium download when installing puppeteer. If you do,
# you'll need to launch puppeteer with:
# browser.launch({executablePath: 'google-chrome-unstable'})
# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
# From node 15 we need to define WORKDIR before running npm install
WORKDIR /usr/app
COPY ./ ./
ENV DISPLAY=:0
# Install puppeteer so it's available in the container.
RUN npm init -y && \
npm i puppeteer \
# Add user so we don't need --no-sandbox.
# same docker layer as npm install to keep re-chowned files from using up several hundred MBs more space
&& groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser ./node_modules \
&& (node -e "require('child_process').execSync(require('puppeteer').executablePath() + ' --credits', {stdio: 'inherit'})" > THIRD_PARTY_NOTICES)
# Run everything after as non-privileged user.
USER pptruser
ENTRYPOINT ["google-chrome-stable"]
If I try I get
|
I experienced an issue in Azure Pipelines, where I could not run a headless Puppeteer:
I eventually fixed the issue by running Xvfb and sending Puppeteer's output to Xvfb. My azure pipeline YAML:
In the forementioned script, it is this part that covers the correct execution of Puppeteer
I also had to the display parameter to my browser env variables in my Puppeteer script
The combination of Xvfb running in the background and Puppeteer outputting to the former's listening port, works for me. |
I was having the same issue in kali trying to install and run google-chrome. I was getting the following error
Solution for me was to search google in kali, right click, edit application, check the box that say Run in Terminal. |
I got that issue in CI/CD. |
It worked for me as well, thanks Man |
Development mode this worked for me |
@ElGalileo12 Do you need to install this before installing chrome/chromium? If I run this after, I'm still getting the following:
|
thanks worked, i'm running it on node.js using command |
Hi, run below cmd to install google chrome - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb facing same error on ubuntu, Any suggestions to solve the error. ERROR:ozone_platform_x11.cc(238)] Missing X server or $DISPLAY |
how can i upvote this answer with recursion that have no limit? |
I have still the similar issue:
|
@StackedQueries Thank you so much mate, you literally save my day. mua~ |
export XAUTHORITY=$HOME/.Xauthority && chromium-browser |
Was experiencing the same below code helped in solving the issue
|
I use this tip and I can run 37 scripts with Puppeteer. But when I run 38 script, I see:
Why? |
In my particular case, I'm using Ubuntu Desktop 22 and I was having this issue. The way that I solved it was adding const pupOpts = {
headless: false,
executablePath: `${process.env.CHROME_PATH}`,
env: {
DISPLAY: ':0',
},
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--no-first-run',
'--no-zygote',
],
} I hope this help someone else |
Had this issue on Ubuntu server 22.04 but 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 |
The Puppeteer documentation has a guide to running a specific file where there is a browser launch using Puppeteer, the Dockerfile itself In my Dockerfile, I inherited the developers' docker image and started my own project: FROM ghcr.io/puppeteer/puppeteer:latest
WORKDIR /home/pptruser
USER root
RUN apt-get update
COPY package.json .
COPY package-lock.json .
COPY tsconfig.json .
COPY src ./src
COPY index.ts .
COPY .env .
COPY fonts fonts/
COPY jest.config.ts .
COPY .prettierrc.json .
RUN npm ci
COPY .env ./dist/
COPY fonts ./dist/fonts/
RUN npm run build
COPY dist /app/dist
EXPOSE 8000
CMD ["node", "dist/index.js"] My puppeteer launch options for docker: const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox'],
executablePath: '/usr/bin/google-chrome'
}); And the work is good. You can also use |
THIS worked for me! I am running Ubuntu20 on an Azure server. I have just chromium installed via snap so this is what I ran:
|
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.
google-chrome |
I was getting the same error on Github Actions and for me the problem was that in my karma.conf.js I was using "Chrome" in the browsers array. |
For anyone who still having this issue on linux desktop environments and wan't to use without headless mode (I'm using ubuntu 24 desktop as non-remote desktop environment), check if your desktop uses wayland. Switching from wayland to xorg was in my case the solution. |
I came across this issue when I was trying to use puppeteer in a Docker container. I tried a mix of the solutions here and came up with a not so pretty solution, but solution that works, at least for me. Here is the Docker file: # Use Ubuntu V22.04 image
FROM ubuntu:22.04
# Install necessary packages including Node.js, npm, xvfb, and other dependencies
RUN apt-get update && apt-get install -y \
curl \
gnupg \
ca-certificates \
apt-transport-https \
software-properties-common \
wget \
dbus-x11 \
xvfb \
ffmpeg \
xauth \
vim-common \
libnss3 \
libxss1 \
libpulse0 \
libasound2 \
libasound2-plugins \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libdbus-glib-1-2 \
libgbm1 \
libxkbcommon-x11-0 \
libgtk-3-0 \
&& curl -sL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& curl --location --silent https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create and change to the app directory
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy local code to the container image
COPY . .
# Set environment variables
ENV DISPLAY=:99
ENV XAUTHORITY=/root/.Xauthority
# ... other environment variables
# Expose the port
EXPOSE 8080
# Copy the startup script to the container
COPY startup.sh /usr/src/app/startup.sh
# Make the startup script executable
RUN chmod +x /usr/src/app/startup.sh
# Run the web service on container startup
CMD ["/usr/src/app/startup.sh"] Here is the startup shell script that is used to write the Xauthority file to authorize connection to the :99 display, and also setup the Xvfb server: #!/bin/bash
# Start Xvfb
Xvfb :99 -screen 0 1920x1080x24 &
# Wait for Xvfb to start
sleep 2
# Set the DISPLAY environment variable (redundant but just to make sure)
export DISPLAY=:99
# Generate a .Xauthority file
touch /root/.Xauthority
xauth generate $DISPLAY . trusted
xauth add $DISPLAY . $(xxd -l 16 -p /dev/urandom)
# Set XAUTHORITY environment variable
export XAUTHORITY=/root/.Xauthority
# Run the web service
dbus-run-session node subService.js # Start the dbus-daemon instance for my subscription service
# For a quick test to see if Xvfb runs at all, you can replace with the command below instead
# dbus-run-session -- xvfb-run --server-args='-screen 0 1920x1080x24' node subService.js
# Since I run Xvfb already within my code, having it try to run twice on the same port might bring in
# errors (at least that is what I get on my end hehe, might work for you) Resources you might find useful: |
I'm having this same issue. @nitsik did you find a resolution? |
Im using Arch in Wsl2 and I'm getting the same error (installing with yay -S chromium): I found this --ozone-platform param that It permit me to open chromium. chromium --ozone-platform=wayland If u having the same error yet try to change the param: |
I solved with in
|
I solved this with this link: https://pptr.dev/guides/headless-modes using:
I'm working with nodejs 20 and red hat 8, I don't use any GUI, just needed to create a file and read it to get the base64 code. |
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. (/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
The text was updated successfully, but these errors were encountered: