Recommended Free Tools
There is no established Pyppeteer rule that closes every connection after one minute. A close means something between your Python code and Chrome stopped communicating: the browser may have exited, the DevTools WebSocket may have dropped, your application may have cancelled work or shut down its event loop, or a network intermediary may have interrupted the connection. Find which component closed first before changing timeouts or dependency versions.
What “connection closed” means in Pyppeteer
Pyppeteer controls Chromium through the Chrome DevTools Protocol, which uses a WebSocket connection. With launch(), Pyppeteer starts a browser process. With connect(), it attaches to a browser that is already running, using that browser’s WebSocket endpoint. A connection error tells you that communication ended; it does not, by itself, tell you why.
The apparent one-minute pattern may be significant in your particular setup, but the available reports do not establish a universal 60-second Pyppeteer timeout. Similar messages—including “connection unexpectedly closed,” “WebSocket connection is closed,” and “Websocket connection is lost”—can come from different causes. The exact exception, its timing, and what the browser process was doing matter more than the wording alone.
Keep an operation timeout separate from a transport failure. A navigation or selector wait can time out while the WebSocket is still healthy. Increasing that operation’s timeout may help a genuinely slow page, but it does not reopen a WebSocket that has already closed.
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 reinstallCrashes, 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 minute#1 Best Overall
Start with these checks
- Record the environment. Write down the Python, Pyppeteer, Chromium, and
websocketsversions; operating system; whether a container, proxy, or remote host is involved; and whether your code useslaunch()orconnect(). - Save the complete first traceback. Include logs from just before the failure. Identify the earliest transport or close exception, rather than diagnosing from the last line alone.
- Check whether Chromium is alive at the moment of failure. If the process has exited, investigate why it terminated. If it is still running, check whether the endpoint and network path remain reachable.
- Check application lifecycle. Look for code that closes the browser, cancels a task, exits an async context, or stops the event loop near the time the connection drops.
- Reproduce with a controlled browser and dependency set. Compare Pyppeteer’s bundled Chromium with your custom executable, then vary dependency versions one at a time.
These checks narrow the problem without assuming the elapsed minute is the cause. Change one condition at a time and preserve the original traceback so you can tell whether a change altered the initiating failure or only a later cleanup error.
Determine whether the browser or the connection closed
If you use launch()
Check the Chromium process and browser logs at the failure timestamp. If Chromium exited, investigate process termination, memory or other resource limits, container policies, operating-system logs, and whether another part of the program called browser.close(). A Python-side WebSocket timeout is unlikely to be the complete explanation if the browser process itself has gone away.
If you use connect()
Confirm that the configured browserWSEndpoint belongs to the intended live browser instance. The endpoint must remain reachable from the Python process, not merely from the machine or container running Chrome. If the browser is alive but the connection drops, inspect the path between them, including proxies, tunnels, firewalls, and container networking. Also check the remote browser’s own logs and idle-session policy, if it has one.
Compare evidence, not guesses
| Observation | What it points toward | Next check |
|---|---|---|
| Chromium process is gone | Browser termination, resource pressure, explicit cleanup, or host/container lifecycle | Browser and host logs; shutdown code; resource limits |
| Chromium is alive, endpoint is unreachable | Endpoint mismatch or a network/intermediary problem | Exact WebSocket endpoint; routing, proxy, firewall, and container path |
| Chromium and endpoint appear healthy, but a page operation times out | Slow navigation or wait condition may be distinct from transport closure | First exception; operation and wait condition; whether later commands still work |
| Failure tracks idle time or a particular deployment boundary | Possible idle cleanup or intermediary connection policy | Compare idle versus active runs and test directly without the intermediary |
| Failure appears only with one browser or dependency combination | Possible compatibility difference | Record exact versions and reproduce with a controlled combination |
These patterns are diagnostic clues, not proof. A process can be alive while its WebSocket is unusable, and a reported operation timeout can be followed by a separate transport failure. Use timestamps and the first exception to establish event order.
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 →Check Pyppeteer, Chromium, and websockets compatibility
Pyppeteer’s documentation for version 0.0.25 says it works best with its bundled Chromium and does not guarantee compatibility with arbitrary Chromium versions. If you supply a custom executable, first reproduce using the bundled browser where possible. If that changes the result, record both browser versions and test whether the behavior consistently follows one combination before settling on a fix.
A historical issue reported a connection closure with websockets 7.0. That is evidence that dependency compatibility has been a concern in at least one reported environment, not a current universal recommendation to install or pin that version. Record your installed package versions with python -m pip show pyppeteer websockets, then test a controlled dependency change in an isolated environment. Avoid changing Pyppeteer, Chromium, and websockets together: if the symptom changes, you will not know which change mattered.
Pyppeteer is an unofficial port of Puppeteer, and its maintenance status can change. For a production system, consider whether the project and browser versions you depend on fit your maintenance requirements. That consideration is separate from identifying the component that closed this particular connection.
Use timeouts only for the operation that timed out
Before raising a timeout, classify the exception. If a navigation, selector wait, or other page operation reached its configured limit while the browser connection remained usable, an appropriately longer operation timeout may be warranted. If the WebSocket is closed, a larger navigation timeout merely allows the operation to wait longer before failing; it does not repair the transport.
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 →Rank #3
Likewise, do not add automatic retries until you know what is safe to repeat. A retry may be reasonable for an idempotent screenshot or read-only page load after a transient network failure, but it can duplicate side effects if the page action submits a form, places an order, or changes remote state. Recreate a fresh browser connection only after confirming the previous browser’s state and the behavior of the work being retried.
Handle the first exception, not just cleanup noise
A reported Pyppeteer failure showed ConnectionClosedOK followed by InvalidStateError during connection cleanup. That sequence illustrates why the first close is often more useful than a later cleanup exception. Preserve the entire traceback and surrounding logs. If cleanup itself is failing, fix it after you have identified what initiated the disconnect; otherwise the secondary error can obscure the original event.
For a useful incident record, capture the time, full exception chain, browser process state, connection mode, browser endpoint identity (redact credentials or sensitive tokens), version output, and any relevant proxy or container boundary. Do not publish a live WebSocket endpoint or access credentials in a bug report.
Troubleshooting common symptoms
“It always happens at about 60 seconds”
Measure whether the interval starts at process launch, connection establishment, navigation, or the last browser activity. Compare an idle connection with one that performs a harmless page operation during the interval. If the delay follows an idle period and Chrome remains alive, examine idle handling in the remote browser service or intermediaries. The timing alone does not identify which one is responsible.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
It happens only in a container or through a proxy
Run a controlled comparison on the same host without that boundary, if feasible. Verify that the container can reach the exact browser endpoint and that the proxy or tunnel permits the WebSocket connection for the required duration. If only one path fails, inspect that boundary’s logs and policy rather than changing page-operation timeouts.
It started after changing Chromium or a package
Restore a known working combination in an isolated environment, then test one version change at a time. Keep a record of the executable actually launched; a system Chromium may differ from Pyppeteer’s bundled copy. Do not infer that a historical issue’s dependency version is the right pin for a current setup.
The page is slow, then the connection error appears
Check the order of events. A slow navigation may reach its operation timeout while the connection remains available, or the browser may independently exit during navigation. Test whether a simple command still works after the operation timeout, and check Chromium’s process state at the same moment. The first failure distinguishes those paths.
The only visible error is InvalidStateError
Look earlier in the log for the original close event. A cleanup failure may be secondary; report both exceptions and their order instead of treating the final message as the root cause.
Best Value
- Used Book in Good Condition
Or skip the browser setup
If your real goal is to obtain website screenshots rather than maintain a Pyppeteer browser connection, ScreenshotNeo offers a screenshot API and MCP server. It is an alternative workflow, not a repair for a broken Pyppeteer process or WebSocket. A Python request for a screenshot of Stripe looks like this:
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)
See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Learn about ScreenshotNeo or sign up free for 1,000 screenshots a month with no card.
Frequently Asked Questions
What information should I include when asking for help with a Pyppeteer disconnect?
Share a redacted traceback, Python/Pyppeteer/Chromium/websockets versions, operating system, whether you use launch() or connect(), and whether a proxy, container, or remote browser is involved. Include the browser process state at the failure time, but remove credentials and live WebSocket endpoint tokens.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsDoes the phrase “WebSocket connection is closed” identify a specific Pyppeteer bug?
No. Similar wording appears across reports with different environments and circumstances. Use the exact traceback and event sequence to diagnose your instance.
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.

