Home > Back-end >  Failed to launch the browser process! Ubuntu
Failed to launch the browser process! Ubuntu

Time:04-08

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

CodePudding user response:

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

CodePudding user response:

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.

  • Related