Free tools Windows power users keep installed
One-click scans. No signup required.
“Browser closed unexpectedly” means Chromium exited before Pyppeteer could connect to its DevTools endpoint. The message is a startup symptom, not a diagnosis. In AWS Lambda, the usual causes are an incompatible Chromium build, missing shared libraries, an incorrect executable path or permissions, architecture mismatch, or insufficient temporary storage. Start by exposing Chromium’s own stderr, then test the exact binary inside the deployed Lambda runtime.
What the exception actually means
Pyppeteer starts Chromium as a child process and waits for Chromium to publish a DevTools WebSocket URL. If Chromium terminates first, the launcher raises BrowserError('Browser closed unexpectedly: ...'). Pyppeteer cannot identify the underlying reason from that event alone.
The failure can therefore occur even when your Python code is valid, the executable exists, and familiar headless flags are present. A binary that works on a workstation may still fail in Lambda because the operating-system libraries, CPU architecture, sandbox environment, or browser version differ.
First diagnostic: expose Chromium’s stderr
Pyppeteer pipes browser output internally by default. Set dumpio=True so startup messages reach CloudWatch Logs. Run this minimal handler before changing launch flags:
#1 Best Overall
import asyncio
import os
from pyppeteer import launch
async def capture(url):
browser = await launch(
executablePath=os.environ.get("CHROMIUM_PATH", "/opt/chromium"),
headless=True,
dumpio=True,
args=["--no-sandbox"]
)
try:
page = await browser.newPage()
await page.goto(url, {"waitUntil": "networkidle2", "timeout": 60000})
return await page.title()
finally:
await browser.close()
def lambda_handler(event, context):
return {"title": asyncio.get_event_loop().run_until_complete(
capture(event.get("url", "https://example.com"))
)}
Deploy this exact version and inspect the first browser lines in the function log. Messages such as error while loading shared libraries: libX.so, Permission denied, an illegal instruction, or an architecture error are substantially more useful than the Pyppeteer exception.
Check the deployed executable, not your local copy
Resolve the path and permissions
Log the path that Lambda actually uses and verify it is executable:
import os
import stat
import subprocess
path = os.environ.get("CHROMIUM_PATH", "/opt/chromium")
print("browser path:", path)
print("exists:", os.path.exists(path))
if os.path.exists(path):
mode = os.stat(path).st_mode
print("mode:", oct(stat.S_IMODE(mode)), "executable:", os.access(path, os.X_OK))
print("size:", os.path.getsize(path))
try:
print(subprocess.run([path, "--version"], text=True,
capture_output=True, timeout=15).stdout)
print(subprocess.run([path, "--version"], text=True,
capture_output=True, timeout=15).stderr)
except Exception as exc:
print("version check failed:", repr(exc))
A path that exists in a deployment package can still point to the wrong file, a non-executable file, or a wrapper whose dependencies are absent. Check the uncompressed artifact as Lambda sees it, including layers and the function architecture.
Inspect dynamic libraries in the runtime
Run the same browser binary in an environment matching the Lambda operating-system generation and architecture. Use the platform’s dependency inspection tools (for example, ldd where available) and look for entries marked “not found.” A missing shared object is a packaging or base-image problem; adding Chromium flags cannot supply that library.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteRank #2
- Language: english
- Book - automate the boring stuff with python, 2nd edition: practical programming for total beginners
- It is made up of premium quality material.
A directly relevant Lambda report described Python 3.9, Pyppeteer 2.0.0, and a downloaded headless-chromium that worked locally but failed after deployment. The community answer attributed the failure to missing X11-related libraries and reported success on EC2. Treat that as a hypothesis to verify in your own image, not as proof that every Lambda deployment needs EC2 or those exact libraries.
Align Pyppeteer, Chromium and Lambda architecture
Use a compatible browser build
Pyppeteer can launch its bundled Chromium or a caller-supplied executable through executablePath. Its launcher documentation says the bundled version is the best-supported choice and does not guarantee that an arbitrary external Chromium version will work. Keep the browser build aligned with your Pyppeteer release and the Lambda operating-system generation.
- Confirm whether the function is x86_64 or arm64 and use a browser compiled for that architecture.
- Do not assume a binary downloaded for another Linux distribution has compatible system libraries.
- Record the Chromium version during deployment and compare it with the Pyppeteer version you install.
- Test the packaged artifact in a container or shell that matches the production Lambda runtime.
Do not treat flags as a universal fix
--no-sandbox, --disable-gpu, --single-process, --disable-dev-shm-usage and --no-zygote are often copied into Lambda examples. The reported failure used those flags and still produced the same exception. Keep only flags required by the verified runtime, and use dumpio=True before experimenting.
Verify Lambda’s writable temporary storage
Lambda exposes temporary storage under /tmp. AWS documents a configurable capacity from 512 MB to 10,240 MB. Browser downloads, extraction, profiles and temporary screenshots can consume it quickly.
Rank #3
import os
import shutil
print("/tmp free bytes:", shutil.disk_usage("/tmp").free)
print("/tmp total bytes:", shutil.disk_usage("/tmp").total)
print("TMPDIR:", os.environ.get("TMPDIR"))
Increase the function’s ephemeral-storage setting when logs show extraction or write failures, or when free space is exhausted. More space can fix storage exhaustion; it cannot fix a missing shared library, an incompatible executable, or a CPU-architecture mismatch. Also remember that /tmp is temporary and tied to an execution environment, so do not use it as durable storage.
A repeatable Lambda debugging sequence
- Enable browser output. Set
dumpio=Trueand reproduce the failure once. - Capture identity data. Log the resolved executable path, permissions, file size, architecture, Chromium version and Pyppeteer version.
- Run the binary directly. Execute its version command and inspect stdout and stderr in a matching Linux environment.
- Inspect dependencies. Find every missing
.solibrary and add a compatible package or rebuild the browser artifact for the target runtime. - Check architecture and browser compatibility. Match x86_64/arm64, Lambda runtime generation and Pyppeteer’s supported Chromium expectation.
- Measure
/tmp. Increase ephemeral storage only when logs or disk measurements indicate a space problem. - Retest with the smallest launch configuration. Add flags one at a time only when a specific error justifies them.
- Choose another environment if necessary. If you cannot provide the required libraries or compatible browser in Lambda, evaluate a container or VM such as EC2 for this workload.
Common symptoms and targeted fixes
| Observed output | Likely cause | Action |
|---|---|---|
error while loading shared libraries |
Missing runtime dependency | Install or bundle the exact library for the target image; verify with dependency inspection. |
Permission denied |
Browser is not executable | Correct file permissions in the layer/package and verify os.access(path, os.X_OK). |
| No browser output, immediate exit | Wrong path, corrupt file or architecture mismatch | Log the path, run --version, check the artifact architecture and redeploy. |
Extraction or write errors under /tmp |
Insufficient ephemeral storage | Free temporary files or raise the configured capacity within AWS’s 512 MB–10,240 MB range. |
| Works locally, fails only in Lambda | Different libraries, kernel/runtime or architecture | Reproduce in a matching Lambda image; local success is not compatibility proof. |
| Failure persists after many flags | Flags are masking a dependency or binary problem | Remove unnecessary flags and rely on Chromium stderr to identify the exit reason. |
Fix Lambda or move the browser?
| Question | Keep the workload in Lambda when… | Consider another environment when… |
|---|---|---|
| Libraries | You can package every required shared library for the runtime. | The browser depends on libraries you cannot supply in the deployment image. |
| Compatibility | Your Chromium build matches the function architecture and Pyppeteer expectations. | The only available browser build targets a different OS generation or CPU. |
| Storage | Download, extraction and profiles fit the configured /tmp capacity. |
Temporary browser data repeatedly exceeds practical ephemeral storage. |
| Operations | Short, isolated invocations suit the job and packaging is repeatable. | You need a persistent browser host or cannot maintain a compatible artifact. |
An individual Lambda user reported moving to EC2 successfully, but that is an anecdotal workaround rather than a universal requirement. Decide from the verified dependency and operational evidence for your workload.
Or skip the browser setup
If your goal is a website image or PDF rather than browser automation itself, ScreenshotNeo provides a single HTTP request. It accepts consent banners like a visitor, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets you turn each cleanup step off. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, with the result identified by X-Page-Verdict and X-Billed headers.
See the parameter reference in the ScreenshotNeo documentation. Replace the example URL with your target:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →cURL
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)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients. It includes full-page capture, lazy-image loading, CSS-selector element capture, device presets, custom JavaScript and CSS, waits, request blocking, cookies, headers, geolocation, PDFs, signed links, asynchronous webhooks and bulk capture. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Start with the free ScreenshotNeo account.
Rank #4
FAQ
Does installing Pyppeteer’s bundled Chromium guarantee Lambda compatibility?
No. It is the best-supported pairing according to Pyppeteer’s documentation, but the browser still must run with the Lambda runtime’s libraries and architecture.
Should I always set --single-process?
No. A directly relevant report used it along with several other flags and still failed. Add launch arguments only when the browser output shows a reason.
Will increasing /tmp fix a missing X11 library?
No. Storage capacity and shared-library availability are separate problems.
What should I preserve when opening a support issue?
Include the Lambda runtime and architecture, Pyppeteer and Chromium versions, resolved executable path, permissions, dumpio output, dependency inspection results and available /tmp space. Redact credentials and private URLs.
Best Value
Frequently Asked Questions
Can a browser that works on my laptop fail in Lambda?
Yes. Local success does not prove that the Lambda image has the same shared libraries, architecture, runtime generation or writable storage.
Is EC2 required for Pyppeteer?
No. One community report succeeded after moving to EC2, but it does not establish that Lambda is universally unsuitable.
The Bottom Line
Treat “Browser closed unexpectedly” as evidence that Chromium exited too early. Chromium’s stderr, the deployed binary’s dependencies, architecture and temporary-storage measurements identify the real fix; copied flags alone do not.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsQuick Recap
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.

