Error deploying Puppeteer on Render.com: "Browser was not found at the configured executablePath"

Hi Render Community,

I’m experiencing an issue while trying to deploy a Node.js application that uses Puppeteer on Render. Despite several attempts and troubleshooting steps, I keep encountering the following error when launching Puppeteer:

Error during Puppeteer usage: Error: Browser was not found at the configured executablePath (/opt/render/.cache/puppeteer/chrome)
    at ChromeLauncher.launch (/opt/render/project/src/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserLauncher.js:76:19)
    ...

Context:

  • Hosting Platform: Render.com
  • Use Case: I am using Puppeteer to perform basic web page analysis, such as visiting https://www.google.com and printing the page title.
  • Puppeteer Versions Tried: I’ve tried both the latest version (^21.0.0) and an older version (19.7.5).
  • Goal: To verify if Puppeteer is installed correctly and runs in the Render hosting environment.

Sample Code:

Here is the sample script (test.js) I am using to verify Puppeteer functionality:

// Import Puppeteer
const puppeteer = require('puppeteer');

// Main function to test Puppeteer
async function testPuppeteer() {
  try {
    // Launch the browser in headless mode with necessary options
    const browser = await puppeteer.launch({
      headless: true,
      args: ['--no-sandbox', '--disable-setuid-sandbox']
    });

    // Create a new page in the browser
    const page = await browser.newPage();

    // Navigate to an example page
    await page.goto('https://www.google.com');

    // Get the page title
    const title = await page.title();
    console.log(`Page title (Google): ${title}`);

    // Close the browser
    await browser.close();

    console.log('Puppeteer is working correctly!');
  } catch (error) {
    // Handle errors if Puppeteer doesn't work correctly
    console.error('Error during Puppeteer usage:', error);
  }
}

// Run the test function
testPuppeteer();

Troubleshooting Steps Taken:

  1. Removed the executablePath Option: I tried removing the executablePath to let Puppeteer automatically locate Chromium.
  2. Tested Different Versions of Puppeteer: I tested with both the latest version (^21.0.0) and 19.7.5.
  3. Postinstall Script in package.json: I added "postinstall": "npx puppeteer install" to ensure that Chromium gets installed during the Render build.
  4. Environment Variable CHROME_BIN: Set CHROME_BIN to /opt/render/.cache/puppeteer/chrome as suggested in various discussions, but the issue persists.

Environment Details:

  • Node.js Version: v20.15.1

Problem Description:

Despite following all these steps, the error persists, indicating that Chromium is not being found at the expected path. It appears that Puppeteer is unable to locate or properly install the browser on Render.com.

Questions:

  • Has anyone else experienced similar issues with deploying Puppeteer on Render?
  • Is there something specific I need to do to make sure Puppeteer can find Chromium in a containerized environment like this?
  • Are there best practices or configurations I may be missing to ensure Puppeteer works on a server environment with restricted installation permissions?

package.json File:

{
  "name": "wcag-web-analyzer",
  "version": "1.0.0",
  "scripts": {
    "start": "node server.js",
    "postinstall": "npx puppeteer install"
  },
  "dependencies": {
    "express": "^4.18.2",
    "axios": "^1.3.0",
    "puppeteer": "^21.0.0",
    "axe-core": "^4.5.4"
  }
}

Thank You!

I appreciate any help or guidance you can provide. I just need to verify if and how Puppeteer can run successfully on Render so I can continue developing the project.

Thanks in advance!

Hi there,

You may be having this issue because you are using an older version of the Puppeteer module. The issue is caused by older versions of Puppeteer not using the updated link to download the most recent Chrome build. (Puppeteer issue refs: 1, 2, +more).

Newer Puppeteer versions have been updated to use the new URL from Chrome, but older versions do not have this fix.

To resolve this issue, you should either update to the latest version of Puppeteer. If this is not possible, you can also work around this issue by creating the PUPPETEER_DOWNLOAD_BASE_URL environment variable and set it to https://storage.googleapis.com/chrome-for-testing-public.

Regards,

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.