Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk8 min

Puppeteer Screenshots on AWS Lambda: Browser Setup and Fixes

A practical guide to matching Puppeteer and Chromium on AWS Lambda, choosing ZIP or container deployment, capturing screenshots, and diagnosing browser startup and blank-page problems.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To take Puppeteer screenshots on AWS Lambda, match the Lambda runtime and CPU architecture to the Chromium build, ship the browser and its native libraries with the function, and choose a Puppeteer version and headless mode that work with that browser. For Node.js 20 and later, AWS Lambda’s Node.js container images use Amazon Linux 2023 (AL2023), not Amazon Linux 2; that changes the package manager and can break older setup recipes.

Check runtime, architecture, and browser compatibility first

A Lambda screenshot function is a bundle of interdependent parts: Node.js, the operating system and its shared libraries, the function’s CPU architecture, Puppeteer, and a compatible Chromium executable. A browser that launches on your laptop is not necessarily deployable to Lambda. Check all five together before debugging screenshot code.

  • Runtime and base image: AWS says Node.js 20 and later Lambda container images are based on AL2023. AL2023 uses microdnf or dnf, rather than yum. An AL2 installation command copied into an AL2023 image may fail.
  • Architecture: Lambda supports x86_64 and arm64. Set the function architecture deliberately and build or obtain the browser and native dependencies for the same architecture. AWS’s architecture guidance does not certify any particular community Chromium build.
  • Browser distribution: A ZIP or layer, a Lambda container image, and a Lambda-compatible Chromium package have different packaging and maintenance trade-offs. Puppeteer’s troubleshooting guide points to the community sparticuz/chromium project as one possible Lambda browser distribution; check that project’s current documentation for its supported runtime, architecture, and Puppeteer compatibility before using it.
  • Puppeteer/browser pairing: Puppeteer v20 moved its supported downloaded browser to Chrome for Testing. From v22, regular headless Chrome is the default; the earlier headless implementation is a separate chrome-headless-shell binary selected with headless: 'shell'. Do not assume an older Lambda Chromium package matches a current Puppeteer release.

The exact executable path, required libraries, and launch arguments depend on the browser package you choose. There is no universal Lambda Chromium path or flag list established by AWS and Puppeteer’s general guidance; use the selected package’s current integration instructions rather than copying flags from an unrelated hosting platform.

Choose ZIP or container image packaging

The browser payload is often the deciding factor. AWS Lambda’s published deployment limits distinguish direct ZIP uploads, extracted deployment contents, and container images:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
40 Pcs/20 Set Rack Mount Screws and Cage Nuts for Server Rack Cabinet, Black Carbon Steel M6 x 20 mm Screws with Nylon Washers and Cage Nuts, Rack Mount Hardware for Server Racks/Shelves/Cabinets
  • Durable Carbon Steel: Rack mount screws and cage nuts are made of high-quality carbon steel with a black finish for high strength and dependable durability.
  • Easy Installation: Clear metric threads and uniform pitch for better grip. Nylon washers help secure screws and protect equipment surfaces.
  • Organized Storage: All parts are packed in a portable storage box for easy organization and access.
  • Wide Compatibility: Fits most square-hole racks and cabinets—ideal for server racks, network cabinets, equipment enclosures, and A/V gear.
  • 20-Set Kit: Includes 20 mounting screws with nylon washers (M6 x 20 mm) and 20 square cage nuts—40 pieces in total—meeting daily install and replacement needs.
Deployment format Published size limit What to consider
ZIP uploaded directly 50 MB Check the compressed archive size. If it is too large, AWS supports uploading the ZIP through S3.
Unzipped ZIP deployment contents, including layers 250 MB Check the total extracted function and layer contents, not just the ZIP file.
Container image 10 GB uncompressed Useful when the browser and system libraries do not fit comfortably in ZIP deployment limits; requires building and maintaining an image.

For a ZIP or layer, inspect both the uploaded archive and the extracted artifact in your build pipeline. For a container, inspect the final image size and confirm that it includes the runtime and browser dependencies. A larger permitted container does not remove the need to keep the browser build aligned with the function architecture and Puppeteer.

Build a minimal Node.js screenshot handler

This handler uses puppeteer-core and an externally supplied Chromium executable. It deliberately takes the path and extra launch arguments from environment variables because different Lambda browser packages expose different locations and launch requirements. Set them according to your selected package’s current instructions.

  1. Include puppeteer-core and the compatible Chromium executable, along with its required libraries, in the Lambda artifact or image.
  2. Set CHROMIUM_EXECUTABLE_PATH to the actual executable path provided by that package. Set CHROMIUM_ARGS_JSON to a JSON array of the package-required launch arguments; if none are required, leave it unset.
  3. Deploy the function for the same architecture as the browser build. Configure the function’s role and invocation method, then test it with a URL you control.
import puppeteer from 'puppeteer-core';

const executablePath = process.env.CHROMIUM_EXECUTABLE_PATH;
const extraArgs = JSON.parse(process.env.CHROMIUM_ARGS_JSON ?? '[]');

export const handler = async (event) => {
  if (!executablePath) {
    throw new Error('Set CHROMIUM_EXECUTABLE_PATH for the deployed Chromium build');
  }

  const url = event?.queryStringParameters?.url;
  if (!url) {
    return {
      statusCode: 400,
      headers: { 'content-type': 'application/json' },
      body: JSON.stringify({ error: 'Provide a url query parameter' }),
    };
  }

  const parsedUrl = new URL(url);
  if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
    return {
      statusCode: 400,
      headers: { 'content-type': 'application/json' },
      body: JSON.stringify({ error: 'Only http and https URLs are supported' }),
    };
  }

  let browser;
  try {
    browser = await puppeteer.launch({
      executablePath,
      args: extraArgs,
      headless: true,
    });

    const page = await browser.newPage();
    await page.setViewport({ width: 1365, height: 900 });
    await page.goto(parsedUrl.href, {
      waitUntil: 'networkidle2',
      timeout: 60000,
    });

    const image = await page.screenshot({ type: 'png', fullPage: true });
    return {
      statusCode: 200,
      headers: { 'content-type': 'image/png' },
      isBase64Encoded: true,
      body: Buffer.from(image).toString('base64'),
    };
  } finally {
    if (browser) await browser.close();
  }
};

For an API Gateway or other HTTP integration, configure binary response handling as required by that integration so the base64-encoded PNG is returned as an image rather than displayed as text. If the function is callable with user-supplied URLs, restrict the allowed destinations: accepting arbitrary URLs can expose internal services reachable from the function’s network.

Page.screenshot() is Puppeteer’s documented page capture method. For a specific element, wait for it to exist and use its element handle’s screenshot() method instead. The example’s networkidle2 wait is suitable for some pages, not every site; applications with persistent network activity may need a different navigation wait and an explicit wait for the content you intend to capture.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
WEAXIO 40 Pack M6x16mm Rack Mount Cage Nuts & Screws & Washers for Rack Mount Server Cabinet, Network Racks Server Shelves, Routers, Server Rack Screws, Square Insert Nuts and Washers, Black Nickel
  • Complete Rack Mount Kit: Includes 40 pack M6x16mm cage nuts, screws, and plastic washers, ideal for securing servers in racks or cabinets
  • Durable & Corrosion-Resistant: Made of metal with black nickel plating for long-lasting strength and rust prevention, perfect for demanding environments like data centers or industrial setups
  • Easy Installation: Spring-loaded cage nuts snap securely into square rack holes, while plastic washers protect equipment surfaces from scratches during tightening
  • Universal Compatibility: Designed for standard 19-inch server racks with square mounting holes, ensuring seamless integration with most rack-mountable hardware
  • Heavy-Duty Performance: Engineered for durability, these nuts and screws support high-stress applications, from data center servers to industrial AV systems

Choose a wait condition and screenshot scope

Wait for the right signal

Navigation completion and visual readiness are not always the same. A site may render its main content after navigation, load images lazily, or keep network requests open. If the screenshot is blank or incomplete, wait for a selector that represents the content you need, or use a suitable delay or navigation condition. Avoid assuming that a single wait setting works for every target.

Capture a page or an element

  • Whole page: page.screenshot({ type: 'png', fullPage: true }) captures beyond the current viewport. Very long pages can take more time and memory than a viewport capture.
  • Viewport: omit fullPage or set it to false when the visible area is all you need; set the viewport before navigation if layout depends on screen size.
  • One element: locate the element, wait until it is present and visible, then call elementHandle.screenshot(). This avoids capturing unrelated page content.
  • Lazy-loaded content: full-page capture does not guarantee every site has loaded every image. Scroll or wait using a site-appropriate strategy before capture if below-the-fold content is important.

Set Lambda memory, timeout, and temporary storage from real runs

AWS Lambda allows memory from 128 MB to 10,240 MB, a timeout up to 900 seconds, and configurable /tmp storage from 512 MB to 10,240 MB. These are service limits, not recommended settings for every screenshot function. Browser startup, page complexity, image dimensions, concurrency, and whether the browser is extracted at runtime all affect the resources required.

Lambda’s /tmp storage is temporary and unique to each execution environment. If your Chromium package extracts files there, or your function writes screenshots there, measure peak use and configure ephemeral storage accordingly. Test with representative pages and capture dimensions; do not infer the needed memory or temporary storage from a successful run on a developer machine.

For reliability, set a navigation timeout that fits within the Lambda timeout, return useful errors to the caller, and always close the browser in a finally block. If you later reuse a browser between invocations to reduce startup work, treat that as a separate lifecycle decision: isolate pages between requests and verify that one failed or slow navigation cannot contaminate another capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Fix common Puppeteer-on-Lambda errors

Symptom Likely cause What to check or change
“Executable not found” or browser launch cannot find Chrome The executable was not included, the configured path is wrong, or a local-machine path was assumed to exist in Lambda. Inspect the built artifact or image. Set the executable path documented or returned by the selected browser package, and verify that the file is available at runtime.
Browser fails immediately or reports a shared-library error Architecture mismatch, missing OS libraries, or an incompatible browser build. Check the Lambda architecture, Chromium build architecture, required libraries, and base image as one set. Follow the browser package’s current integration instructions.
yum is unavailable during a container build The recipe targets Amazon Linux 2 but the Node.js 20+ Lambda base image is AL2023. Use AL2023’s microdnf or dnf where appropriate, and verify package names against the chosen base image.
ZIP upload or deployment exceeds a size limit The compressed ZIP or extracted function-plus-layer contents exceed the relevant Lambda limit. Compare the archive and extracted sizes against AWS’s ZIP limits. Consider an S3 ZIP upload for the direct-upload constraint or a container image if the total bundle requires it.
Extraction or capture runs out of space The browser extraction or screenshot workload exceeds configured /tmp storage. Inspect the package’s extraction behavior, measure temporary-file use, and increase ephemeral storage within Lambda’s allowed range if needed.
Screenshot is blank, partial, or missing images The page was captured before its application content or lazy-loaded resources were ready. Use a wait condition suited to the page, then explicitly wait for the relevant selector or content. Test viewport and full-page behavior separately.
Current Puppeteer launches the wrong headless binary The Puppeteer release’s default headless mode differs from the binary shipped with the function. For Puppeteer v22 and later, regular headless Chrome is the default; use headless: 'shell' only when shipping the compatible chrome-headless-shell and that mode suits the workload.
Copied launch flags seem necessary but browser still fails Flags taken from another platform may not match this runtime or browser package. Use the selected package’s required arguments and diagnose architecture, libraries, and version pairing rather than cargo-culting unrelated flags. Puppeteer’s --no-sandbox advice in its troubleshooting page concerns Heroku and is not a universal Lambda prescription.

When to choose regular headless Chrome or headless shell

Puppeteer describes chrome-headless-shell as currently more performant for automation that does not need the full Chrome feature set, but it does not behave identically to regular Chrome. Prefer regular headless Chrome when compatibility with Chrome’s regular feature behavior matters. Consider the shell only after confirming that your workload is compatible and that the selected browser distribution supplies the matching binary. The Puppeteer version, executable, and headless setting must agree.

Or skip the browser setup

If your goal is to get screenshots rather than maintain a Lambda browser bundle, ScreenshotNeo provides a website screenshot API and MCP server. Here is a one-request cURL example; the ScreenshotNeo documentation covers its API options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.