Failed to launch the browser process! Ubuntu

5.9k Views Asked by At

Puppeter not working on Ubuntu server. This is my code.

const browser = await puppeteer.launch({
        args: ["--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu"],
        headless: false,
        executablePath: '/usr/bin/chromium-browser',
        ignoreDefaultArgs: ['--disable-extensions'],
      });

enter image description here

4

There are 4 best solutions below

0
On

The answer is in the error msg:

Missing X server or $DISPLAY

You can only run chrome in headless mode by default on the server as it doesn't have a display screen. That's why you get the error.

headless: false,

line should be either removed or modified to:

headless: true,

There are alternative ways to fake headful mode on the server, but it heavily depends on your environment what works for you and these are non-stable workaround solutions. e.g.

3
On

Possibly due to missing Ubuntu dependency

Install all the required dependencies for Puppeteer with the following command.

sudo apt-get install -y libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb libgbm-dev

Source

0
On

I was facing the same error yesterday.

you have to install and setup x-server as described in this link

1
On
Xvfb -ac :99 -screen 0 1280x1024x16 &
 export DISPLAY=:99