Buglesstack is in beta development. Get started

Failed to launch chrome! spawn /usr/bin/chromium-browser ENOENT

Learn how to fix the 'Failed to launch chrome' error when Chromium browser is not found in the expected location


Failed to launch chrome! spawn /usr/bin/chromium-browser ENOENT

This error occurs when Puppeteer cannot find the Chrome/Chromium browser executable in the expected location. Let’s explore the causes and solutions.

Common Causes

  • Missing Chrome/Chromium installation: The browser is not installed on your system
  • Wrong executable path: Puppeteer is looking in the wrong location
  • Permission issues: The browser executable lacks proper permissions
  • Incorrect Puppeteer configuration: The executable path is not properly specified

Solutions

1. Install Chrome/Chromium

For Ubuntu/Debian:

sudo apt-get update
sudo apt-get install chromium-browser

For macOS:

brew install chromium

2. Specify the correct executable path

You can explicitly tell Puppeteer where to find Chrome:

const browser = await puppeteer.launch({
  executablePath: '/usr/bin/chromium-browser', // Linux
  // or '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' for macOS
});

3. Use Puppeteer’s bundled Chrome

The simplest solution is to use Puppeteer’s built-in Chrome:

const browser = await puppeteer.launch({
  product: 'chrome',
  headless: true
});

4. Check file permissions

Ensure the Chrome executable has proper permissions:

sudo chmod +x /usr/bin/chromium-browser

Still Encountering Issues?

If you’re still having trouble launching Chrome, you can use a visual testing tool like Buglesstack to debug your automation setup and verify browser configurations.

// .. assuming you already have your Puppeteer browser and page initialized

try {
	await page.goto('https://www.google.com/search?q=puppeteer');		
	await page.waitForSelector('[name="q"]');
}
catch (error) {
	// Prepare buglesstack data
	const buglesstackData = {
		url: page.url(),
		screenshot: await page.screenshot({ encoding: 'base64' }),
		html: await page.content(),
		metadata: {},
		message: error.message,
		stack: error.stack
	};

	// Get your access token from https://app.buglesstack.com
	const ACCESS_TOKEN = 'HERE_YOUR_ACCESS_TOKEN';

	// Send error to buglesstack
	await axios.post('https://app.buglesstack.com/api/v1/crashes', buglesstackData, {
		headers: {
			Authorization: `Bearer ${ACCESS_TOKEN}`,
			'Content-Type': 'application/json'
		}
	});
		
	// Re-throw the error to propagate it
	throw error;
}

By properly configuring Chrome paths and permissions, you can resolve the “Failed to launch chrome” error and get your automation running smoothly.

Save days debugging your
browser automation

Speed up production debugging with instant visualizations of your browser automation crashes.