🚀 How to Install Chromium for Puppeteer on AWS (EC2 or Lambda)

🧠 Why This Happens

AWS environments (like Amazon Linux 2 on EC2 or Lambda) don’t come with Chromium installed by default. Also, the headless version Puppeteer tries to download is often incompatible with AWS’s OS.

To make Puppeteer work, you need:


This content originally appeared on DEV Community and was authored by Kaibalya Kar

🧠 Why This Happens

AWS environments (like Amazon Linux 2 on EC2 or Lambda) don’t come with Chromium installed by default. Also, the headless version Puppeteer tries to download is often incompatible with AWS's OS.

To make Puppeteer work, you need:

  1. A compatible headless Chromium binary.

  2. Proper dependencies installed (fonts, sandbox libs, etc.).

  3. The right launch options.

🧠 Why This Happens

AWS environments (like Amazon Linux 2 on EC2 or Lambda) don’t come with Chromium installed by default. Also, the headless version Puppeteer tries to download is often incompatible with AWS's OS.

To make Puppeteer work, you need:

  1. A compatible headless Chromium binary.

  2. Proper dependencies installed (fonts, sandbox libs, etc.).

  3. The right launch options.

sudo yum update -y

# Install missing libraries
sudo yum install -y \
  atk.x86_64 \
  cups-libs.x86_64 \
  gtk3.x86_64 \
  libXcomposite.x86_64 \
  libXcursor.x86_64 \
  libXdamage.x86_64 \
  libXext.x86_64 \
  libXi.x86_64 \
  libXrandr.x86_64 \
  libXss.x86_64 \
  libXtst.x86_64 \
  pango.x86_64 \
  alsa-lib.x86_64 \
  ipa-gothic-fonts \
  xorg-x11-fonts-100dpi \
  xorg-x11-fonts-75dpi \
  xorg-x11-utils \
  xorg-x11-fonts-cyrillic \
  xorg-x11-fonts-Type1 \
  xorg-x11-fonts-misc \
  wget

✅ Step 2: Download a Compatible Chromium Binary

cd ~
mkdir chromium && cd chromium

wget https://github.com/Sparticuz/chromium/releases/download/v123.0.0/chromium.br
# OR another known working build for Amazon Linux

# Decompress
brew install brotli # if needed
brotli --decompress chromium.br
chmod +x chromium

✅ Step 3: Point Puppeteer to This Chromium

Now in your Node.js code:

import puppeteer from 'puppeteer-core';

const browser = await puppeteer.launch({
  executablePath: '/home/ec2-user/chromium/chromium',
  headless: true,
  args: [
    '--no-sandbox',
    '--disable-setuid-sandbox',
  ],
});

☁️ Bonus: Using Puppeteer with Chromium in AWS Lambda?

Use chrome-aws-lambda:

npm install puppeteer-core chrome-aws-lambda

Then:

import chromium from 'chrome-aws-lambda';
import puppeteer from 'puppeteer-core';

export const handler = async () => {
  const browser = await puppeteer.launch({
    args: chromium.args,
    defaultViewport: chromium.defaultViewport,
    executablePath: await chromium.executablePath,
    headless: chromium.headless,
  });

  const page = await browser.newPage();
  await page.goto('https://example.com');
  const screenshot = await page.screenshot();

  await browser.close();

  return screenshot;
};

🧪 Test It

After setup:

node yourScript.js

✅ If all goes well, Chromium should launch and Puppeteer will work as expected!

✅ Summary

Task Done

Install system dependencies ✅
Download compatible Chromium ✅
Launch Puppeteer with custom binary ✅

Running Puppeteer on AWS isn’t plug and play and but once Chromium is correctly installed and referenced, everything runs smoothly.


This content originally appeared on DEV Community and was authored by Kaibalya Kar


Print Share Comment Cite Upload Translate Updates
APA

Kaibalya Kar | Sciencx (2025-07-21T20:43:04+00:00) 🚀 How to Install Chromium for Puppeteer on AWS (EC2 or Lambda). Retrieved from https://www.scien.cx/2025/07/21/%f0%9f%9a%80-how-to-install-chromium-for-puppeteer-on-aws-ec2-or-lambda/

MLA
" » 🚀 How to Install Chromium for Puppeteer on AWS (EC2 or Lambda)." Kaibalya Kar | Sciencx - Monday July 21, 2025, https://www.scien.cx/2025/07/21/%f0%9f%9a%80-how-to-install-chromium-for-puppeteer-on-aws-ec2-or-lambda/
HARVARD
Kaibalya Kar | Sciencx Monday July 21, 2025 » 🚀 How to Install Chromium for Puppeteer on AWS (EC2 or Lambda)., viewed ,<https://www.scien.cx/2025/07/21/%f0%9f%9a%80-how-to-install-chromium-for-puppeteer-on-aws-ec2-or-lambda/>
VANCOUVER
Kaibalya Kar | Sciencx - » 🚀 How to Install Chromium for Puppeteer on AWS (EC2 or Lambda). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/07/21/%f0%9f%9a%80-how-to-install-chromium-for-puppeteer-on-aws-ec2-or-lambda/
CHICAGO
" » 🚀 How to Install Chromium for Puppeteer on AWS (EC2 or Lambda)." Kaibalya Kar | Sciencx - Accessed . https://www.scien.cx/2025/07/21/%f0%9f%9a%80-how-to-install-chromium-for-puppeteer-on-aws-ec2-or-lambda/
IEEE
" » 🚀 How to Install Chromium for Puppeteer on AWS (EC2 or Lambda)." Kaibalya Kar | Sciencx [Online]. Available: https://www.scien.cx/2025/07/21/%f0%9f%9a%80-how-to-install-chromium-for-puppeteer-on-aws-ec2-or-lambda/. [Accessed: ]
rf:citation
» 🚀 How to Install Chromium for Puppeteer on AWS (EC2 or Lambda) | Kaibalya Kar | Sciencx | https://www.scien.cx/2025/07/21/%f0%9f%9a%80-how-to-install-chromium-for-puppeteer-on-aws-ec2-or-lambda/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.