Free tools Windows power users keep installed
One-click scans. No signup required.
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
A Pyppeteer connection that closes after roughly a minute does not, by itself, point to a one-minute Pyppeteer timeout. The browser process, its DevTools WebSocket, Python’s WebSocket client, your application’s event loop or task, or a network intermediary may be closing. Find which one stops first before changing timeouts or dependencies: a longer navigation timeout cannot repair a WebSocket that is already closed.
First identify what is closing
Pyppeteer controls Chrome through a browser WebSocket endpoint. A failure reported as “connection unexpectedly closed,” “WebSocket connection is closed,” or “Websocket connection is lost” describes what a caller observed; the wording alone does not identify the cause. Reports from different environments show different exception types and timings, not a universal one-minute failure rule.
Start with the earliest exception and the state of the browser at that moment. A later exception during cleanup may be a consequence of the initial disconnect, not its cause. One reported sequence included ConnectionClosedOK followed by InvalidStateError during cleanup. Preserve the whole traceback and the log lines immediately before it.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →- Browser exited: investigate why the Chromium process stopped, including application shutdown, resource limits, and browser logs.
- Browser is alive, endpoint is unreachable: check the configured WebSocket endpoint and any proxy, container, or network boundary between Python and Chrome.
- Browser and endpoint remain available: inspect whether your application cancelled a task, closed the browser, or shut down its event loop.
- Only a particular operation fails: determine whether it is a navigation, selector wait, or other operation timeout rather than a transport disconnect.
Collect the details that distinguish causes
Before editing code, write down the environment and preserve evidence from a failure. “It happens after a minute” is useful timing information, but it is not enough to establish an idle timeout, a Pyppeteer default, or a particular dependency bug.
#1 Best Overall
- Python, Pyppeteer, Chromium, and
websocketsversions. - Operating system and whether the code runs in a container or crosses a proxy or other network intermediary.
- Whether the application starts Chrome with
launch()or attaches to an existing browser withconnect(). - The complete traceback, especially the first close or transport exception, plus application and browser logs immediately before it.
- Whether the browser process was still running when the failure occurred, and whether the failure followed an operation, a period of inactivity, or application shutdown.
Do not reduce the report to the final line of the traceback. The initiating close, close code, surrounding logs, and process state are more useful than a cleanup exception in isolation.
Follow this diagnostic sequence
- Capture one complete failure. Record the versions and connection mode above, then save the entire traceback and preceding logs. Do not change several dependencies or timeouts before you have a baseline.
- Check Chromium at the failure time. If its process has exited, focus on process termination, resource limits, application cleanup, and browser logs. If it is still running, do not assume that the browser is healthy merely because the process exists; continue to endpoint and application checks.
- If using
connect(), verify the endpoint. Confirm thatbrowserWSEndpointbelongs to the live browser instance you intend to control. Pyppeteer’s API requires a browser WebSocket endpoint for this connection mode. Check whether that exact endpoint remains reachable when the failure occurs, and inspect any proxy or container boundary along the route. - If using
launch(), inspect ownership and shutdown. Determine whether your application, a surrounding task, or its shutdown path closes the launched browser or stops the event loop. Compare the process state before and after the disconnect rather than inferring the cause from the exception wording. - Compare browser compatibility in a controlled run. Pyppeteer’s 0.0.25 API documentation says it works best with its bundled Chromium and does not guarantee compatibility with an arbitrary executable. Reproduce with bundled Chromium when possible; then compare against the custom browser version while keeping the rest of the environment fixed.
- Investigate dependency versions only after recording them. A 2018 issue reported a closure with
websockets7.0, but that historical report does not establish a current universal version pin or a fix for unrelated failures. Reproduce in a controlled environment before changing or pinning the package. - Adjust a timeout only when that operation is timing out. If the transport is still healthy and a specific navigation or wait exceeds its configured allowance, an operation timeout may be relevant. If the WebSocket has already closed, increasing a navigation or selector timeout does not reopen it.
Compare the likely explanations
Use the evidence you collected to narrow the next check. These are diagnostic branches, not a ranking of proven causes: issue reports describe varying circumstances and cannot identify the cause in a different installation.
| Observation | What it points you toward | Next check |
|---|---|---|
| Chromium has exited | Browser process termination, resource limits, or application cleanup. | Check process and browser logs, resource conditions, and the code path that owns shutdown. |
| Chromium remains alive, but the endpoint cannot be reached | Wrong or stale endpoint, an unavailable DevTools WebSocket, or an intermediary boundary. | Verify the exact endpoint for the live browser and inspect the proxy, container, or network path. |
| Failure follows a specific navigation or wait | An operation may be exceeding its own timeout; a transport close is still a distinct possibility. | Check whether the browser and WebSocket remain healthy when that operation fails. |
| Failure follows idle time or shutdown | An application task, event loop, process owner, or intermediary may be ending the connection. | Correlate the close with task cancellation, application shutdown, browser state, and endpoint reachability. |
| Failure appears only with a custom Chromium or dependency set | A compatibility difference is possible, but correlation alone does not prove which version is responsible. | Reproduce with bundled Chromium and compare controlled dependency configurations. |
Common mistakes and how to recover
Blindly increasing a timeout
A page or navigation timeout governs an operation’s wait; it does not restore a closed browser WebSocket. First establish whether the browser and transport remained alive. Change an operation timeout only if that operation, rather than the connection, is what timed out.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchTreating a cleanup error as the root cause
If an “invalid state” or similar exception appears after a connection-close exception, retain both but investigate the first event. Cleanup code running after a disconnect may itself encounter an already-closed connection.
Rank #3
Changing websockets based on one old report
The reported association with version 7.0 dates to 2018. It is a reason to record and test your installed version, not evidence that a particular downgrade or upgrade will fix a present-day failure. Change one variable at a time and compare a reproducible run.
Assuming every Chrome executable is interchangeable
The Pyppeteer 0.0.25 API documentation recommends its bundled Chromium for best results and gives no compatibility guarantee for arbitrary Chromium versions. If you use a custom executable, compare it with the bundled browser before attributing the disconnect to a timeout.
When you need more evidence
If the sequence does not isolate the closing component, make the next report reproducible rather than offering only the phrase “closes after a minute.” Include the exact traceback, all four version numbers, operating system, launch() or connect() mode, browser process state at failure, whether the endpoint remains reachable, and any proxy or container topology. Also say whether the failure follows a particular operation or idle period. Without those details, the available reports cannot establish a specific fix for your case.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Or skip the browser setup
If your actual goal is to obtain website screenshots rather than to maintain a Pyppeteer browser session, ScreenshotNeo offers a screenshot API and MCP server. It is an alternative workflow, not a repair for an existing Pyppeteer connection. One GET request can return an image or PDF; for example:
Best Value
- Used Book in Good Condition
ScreenshotNeo API documentation
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and each response says which outcome occurred in its X-Page-Verdict and X-Billed headers. Its MCP server gives AI agents tools named take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, with no card.
Conclusion
There is no established universal one-minute Pyppeteer connection timeout to switch off. Diagnose the first close by checking browser process state, the correct live WebSocket endpoint, application and event-loop ownership, network boundaries, and controlled browser and dependency versions. Change a timeout only when the failing operation itself is timing out while the transport remains healthy.
Frequently Asked Questions
Does the phrase “connection unexpectedly closed” identify a specific Pyppeteer cause?
No. Similar close messages occur in reports with different environments and exception types; the first exception and the browser and endpoint state are needed to distinguish them.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Is Pyppeteer an official Python version of Puppeteer?
The repository identifies Pyppeteer as an unofficial port. Its maintenance status can change, so check the current repository and documentation when making a longer-term dependency decision.
Quick 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.

