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

There is no single launch flag that reliably fixes Pyppeteer’s “Browser closed unexpectedly” error on AWS Lambda. Start by proving that your Pyppeteer package, Chromium binary, Lambda runtime, and CPU architecture belong together. Then capture Chromium’s stderr, verify the executable and its libraries, and distinguish a launch crash from a Lambda timeout or environment reset. The incident report commonly associated with this message downloaded Chromium into /tmp, but that detail does not establish that extraction was the cause.

Start with the compatibility check

Pyppeteer’s indexed API Reference (version 0.0.25) says: “Pyppeteer can also be used to control the Chrome browser, but it works best with the version of Chromium it is bundled with. There is no guarantee it will work with any other version.” Treat that as the first diagnostic decision, not as a promise that the bundled browser will run unchanged on Lambda.

  1. Record the deployed Python runtime and operating-system generation, CPU architecture (x86_64 or arm64), Pyppeteer version, Chromium version/build, binary provenance, and every launch argument.
  2. Check whether your code passes executablePath. If it does, establish that the binary was built for the same Lambda OS family and architecture as the Python package and native libraries. A browser copied from another environment can fail before a page is opened.
  3. Prefer a Chromium binary and Python/native dependency set that were built and tested together for your exact Lambda target. Do not assume that a named community layer or package is compatible without a version matrix and provenance.

The report does not include these versions, the architecture, complete stderr, or an accepted resolution, so no particular package, flag, or layer can honestly be called the universal fix.

Python 3.9 is already past its Lambda deprecation date

AWS’s runtime table lists python3.9 on Amazon Linux 2 with a deprecation date of 2025-12-15. The same table projects blocking creation of new Python 3.9 functions on 2027-02-01 and blocking updates on 2027-03-03. These dates can change, so verify the live AWS table when you plan a migration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

For an existing function, this is an operational risk as well as a browser problem. For a maintainable deployment, select a currently supported Python runtime, then rebuild Pyppeteer’s native dependencies and the Chromium artifact for that runtime and architecture. Never copy a Python 3.9/Amazon Linux 2 binary into a different environment without testing its dynamic libraries and permissions.

Make the failure observable before changing flags

Pyppeteer documents dumpio, executablePath, autoClose (documented as defaulting to true), and debug logging through pyppeteer.DEBUG = True. Confirm the options in the version you actually deploy; the indexed reference is old.

Use a handler that logs the launch context, sends Chromium output to the Lambda log stream, and always closes the browser:

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
import asyncio
import json
import logging
import os
from pathlib import Path

import pyppeteer
from pyppeteer import launch

pyppeteer.DEBUG = True
log = logging.getLogger()
log.setLevel(logging.INFO)

async def capture(url: str):
    executable = os.environ.get("CHROMIUM_PATH")
    launch_args = [
        "--no-sandbox",
        "--disable-setuid-sandbox",
        "--disable-dev-shm-usage",
    ]
    log.info("runtime=%s arch=%s pyppeteer=%s chromium=%s args=%s",
             os.environ.get("AWS_LAMBDA_FUNCTION_VERSION"),
             os.uname().machine,
             getattr(pyppeteer, "__version__", "unknown"),
             executable or "bundled",
             launch_args)
    if executable:
        path = Path(executable)
        log.info("chromium_exists=%s executable=%s size=%s",
                 path.exists(), os.access(path, os.X_OK),
                 path.stat().st_size if path.exists() else None)

    browser = None
    try:
        options = {
            "headless": True,
            "dumpio": True,
            "autoClose": False,
            "args": launch_args,
        }
        if executable:
            options["executablePath"] = executable
        browser = await launch(options)
        page = await browser.newPage()
        await page.goto(url, {"waitUntil": "networkidle2", "timeout": 60000})
        return await page.title()
    finally:
        if browser is not None:
            await browser.close()

def lambda_handler(event, context):
    url = event.get("url", "https://example.com")
    return {"statusCode": 200, "body": json.dumps({"title": asyncio.run(capture(url))})}

The three arguments shown above are commonly tested in Lambda deployments, but they are diagnostic candidates, not a confirmed answer for this incident. Keep a record of which change altered the result instead of adding flags blindly.

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

Verify the binary, extraction, and libraries

Check the configured path

  • Log the exact executablePath and confirm Path.exists() and executable permission immediately before launch.
  • If the browser is extracted to /tmp, finish extraction before calling launch(). Log the archive size, extracted file size, and extraction error.
  • Ensure the path is on a writable location only when the extraction process needs one. A read-only deployment directory can be valid if the binary is already executable; do not silently fall back to a nonexistent path.

Check packaging and architecture

Package layout, Lambda layers, and container images all work when the browser and its shared libraries match the runtime. An executable bit lost during packaging, a missing shared library, or an arm64/x86_64 mismatch can make Chromium exit immediately. The stderr emitted by dumpio=True is more useful than guessing at flags.

Check temporary storage

Compressed browser downloads and extraction consume /tmp. Log free space and verify every extraction step. The incident’s mention of /tmp does not prove that space, extraction, or permissions caused its failure.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Separate a browser crash from a Lambda lifecycle failure

Lambda can freeze an execution environment after the runtime and extensions finish, reuse it for a later invocation, reset it after an invocation failure, or terminate it during maintenance. AWS describes this after an invocation failure as: “The Lambda service performs a reset.” A browser process must therefore be started and closed within the invocation; do not rely on a browser surviving environment reuse.

AWS’s troubleshooting guidance considers errors during initialization, handler processing, and return. Use the logs to locate the phase:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Initialization: inspect INIT_REPORT for import, layer, extraction, or startup failures.
  • Invocation: match the invocation’s REPORT line and trace its request ID through the complete CloudWatch stream.
  • Timeout: compare the configured timeout with the elapsed duration in the matching REPORT entry. A timeout can leave you with a misleading browser symptom.
  • Reset: after an invoke error, assume the next invocation may use a fresh environment and repeat all initialization checks.

On-demand initialization has a documented default limit of 10 seconds before Lambda retries initialization at the first invocation with the configured function timeout; provisioned concurrency and other modes have different behavior. Measure your startup rather than assuming this limit applies unchanged to every deployment.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Give startup enough measured resources

Browser startup, page navigation, JavaScript execution, and image rendering compete for memory and time. Increase the function’s memory and timeout only after recording startup and navigation durations in logs. AWS treats memory and maximum execution time as configuration inputs and recommends checking timeout against the expected workload.

  • Set a timeout longer than the slowest expected cold start plus page work and cleanup.
  • Watch for memory pressure during Chromium startup and large pages; a process killed for resource pressure may look like an unexplained close.
  • Use a bounded navigation timeout and return a useful error rather than leaving asynchronous browser work running after the handler returns.
  • Close the browser in finally, including navigation and parsing failures.

Common symptoms and the next check

Symptom Likely branch Next check
Immediate close with no page Binary, architecture, loader, or permission problem Enable dumpio; verify path, executable bit, architecture, and shared-library errors.
Works locally, fails only in Lambda Runtime/OS differences or missing packaged files Log runtime, architecture, versions, and the actual deployment contents.
First invocation times out Initialization or browser startup exceeds limits Inspect INIT_REPORT, matching REPORT, memory, timeout, and extraction duration.
Later invocations fail after one error Environment reset or stale lifecycle assumptions Start a fresh browser per invocation and avoid global browser handles.
Navigation fails after launch Network, target-site, or page timeout Distinguish a successful launch from goto failure in separate logs.
External Chromium fails while bundled one works Unsupported version pairing Use the bundled build or validate the external browser against the deployed Pyppeteer version.

A reproducible deployment checklist

  1. Freeze and record Python, Pyppeteer, Chromium, runtime, OS, architecture, and launch arguments.
  2. Build the browser and native dependencies for that exact target; verify provenance.
  3. Test the binary’s presence and executable permission in the deployed artifact.
  4. Enable pyppeteer.DEBUG and dumpio=True in a controlled test invocation.
  5. Capture INIT_REPORT, REPORT, request ID, stderr, memory, duration, and timeout.
  6. Increase resources based on those measurements, not on a copied configuration.
  7. Use try/finally cleanup and treat every invocation as able to start in a new environment.
  8. Plan migration away from Python 3.9 and rebuild artifacts for the selected supported runtime.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is simply a reliable website screenshot rather than browser automation inside your own Lambda package, ScreenshotNeo provides a hosted API and MCP server. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP tools—take_screenshot, get_page_info, and capture_pdf—let Claude, Cursor, or another MCP client request captures without your packaging Chromium.

One GET request returns PNG, JPEG, WebP, or PDF. The API supports full-page captures with lazy images, CSS-selector element shots, dark mode, device presets or custom viewports, retina scale, PDF paper and page options, custom CSS and JavaScript, clicks, waits, blocked resources, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, TTL caching, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification.

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.

See the ScreenshotNeo documentation for current parameters. cURL:

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots, and every feature is on every plan. Create a free ScreenshotNeo account.

Frequently Asked Questions

Should I set autoClose to false?

It can make cleanup explicit for diagnostics, but it is not a proven fix. Close the browser yourself in a finally block and verify the option in your deployed Pyppeteer version.

Is downloading Chromium into /tmp required?

No. It is one deployment pattern mentioned in the incident report, not a demonstrated requirement or universal remedy. What matters is that extraction completes and the resulting binary is compatible and executable.

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

Can I keep one global browser between Lambda calls?

Do not depend on it. Lambda may freeze, reuse, reset, or terminate environments; create and close the browser within each invocation unless you have measured and deliberately handled reuse failures.

The Bottom Line

Fix this error by collecting evidence in the deployed environment: verify the Pyppeteer–Chromium pairing first, inspect stderr with debug logging and dumpio, validate the binary and libraries, then use Lambda’s initialization and invocation logs to separate crashes from timeouts and resets. Migrate from Python 3.9 rather than carrying an unsupported runtime forward.

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.