Puppeteer on Heroku: Failed to launch the browser process

Viewed 7107

I'm using Puppeteer on Heroku and I receive the following error:

Failed to launch the browser process! /usr/src/app/node_modules/puppeteer/.local-chromium/linux-756035/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md
4 Answers
  1. Declare browser as:

    const browser = await puppeteer.launch({
                      headless: true,
                      args: ['--no-sandbox','--disable-setuid-sandbox']
                    })
    
  2. Install heroku buildpack puppeteer heroku buildpack

  3. Must clear heroku cache

  4. git add .

  5. git commit -m "some text"

  6. git push heroku master

May be this could help (copied from Puppeteer official website)

Running Puppeteer on Heroku (https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-on-heroku)

Running Puppeteer on Heroku requires some additional dependencies that aren't included on the Linux box that Heroku spins up for you. To add the dependencies on deploy, add the Puppeteer Heroku buildpack to the list of buildpacks for your app under Settings > Buildpacks.

The url for the buildpack is https://github.com/jontewks/puppeteer-heroku-buildpack

Ensure that you're using '--no-sandbox' mode when launching Puppeteer. This can be done by passing it as an argument to your .launch() call: puppeteer.launch({ args: ['--no-sandbox'] });.

When you click add buildpack, simply paste that url into the input, and click save. On the next deploy, your app will also install the dependencies that Puppeteer needs to run.

If you need to render Chinese, Japanese, or Korean characters you may need to use a buildpack with additional font files like https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack

There's also another simple guide from @timleland that includes a sample project: https://timleland.com/headless-chrome-on-heroku/.

You cant run Puppeteer on Heroku with headless: false because it doesn't have GUI to show.

You need to use headless: true that's because it's running on a Linux without GUI

If you have another errors, you may want to read the official Puppeteer troubleshooting guide: Running Puppeteer on Heroku.

Related