October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Disconnect from a Puppeteer Browser Without Closing It

Detach Puppeteer from a browser without closing it: use browser.disconnect(), save the WebSocket endpoint to reconnect, and reserve browser.close() for shutdown.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use await browser.disconnect() to detach Puppeteer while leaving the browser process and its pages open. Use await browser.close() only when you want to shut down the browser. Save the WebSocket endpoint before disconnecting if you may need to reconnect.

Disconnect Puppeteer without closing the browser

Call disconnect() on the Puppeteer Browser instance. It returns a Promise<void>; await it so your code waits for the client to detach. Puppeteer documents that this leaves the browser process running, and its browser-management guide says the pages are not closed by the disconnect.

As an Amazon Associate I earn from qualifying purchases.

const browser = await puppeteer.launch();

// Keep this if you may reconnect later.
const browserWSEndpoint = browser.wsEndpoint();

// Detach Puppeteer; the browser and its pages remain open.
await browser.disconnect();

The same Browser API applies whether Puppeteer launched the browser or connected to an already-running browser.

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

Reconnect to the same browser

Capture browser.wsEndpoint() before disconnecting, then pass the saved endpoint as browserWSEndpoint to puppeteer.connect(). This is Puppeteer’s documented reconnect pattern:

const browser = await puppeteer.launch();
const browserWSEndpoint = browser.wsEndpoint();

await browser.disconnect();

const browserAgain = await puppeteer.connect({ browserWSEndpoint });

// Close only when you intend to shut down the browser.
await browserAgain.close();

For an independently running browser, connect with its WebSocket endpoint, use it, and call browser.disconnect() when you want to detach. The endpoint must still be available to the process reconnecting; Puppeteer’s example does not guarantee how long a third-party hosting environment keeps an endpoint valid. See the Browser class reference, the browser-management guide, and the connect() reference.

Choose between disconnect() and close()

Method Effect Use it when
browser.disconnect() Detaches Puppeteer; leaves the browser process and its pages open. You want to stop controlling the browser from this Puppeteer client but keep it running.
browser.close() Closes the browser and its associated pages. You intend to shut down the browser.

These behaviors are described in Puppeteer’s Browser.disconnect() reference and Browser.close() reference. Do not substitute close() when your goal is only to detach.

Troubleshooting disconnect and reconnect

  • The browser closed unexpectedly: Check that your code called disconnect(), not close(). Also account for any separate host or process supervisor; Puppeteer’s documented behavior does not establish how every external environment manages browser processes.
  • Reconnect fails: Confirm you saved the endpoint before disconnecting and pass it as browserWSEndpoint to puppeteer.connect(). Verify that the endpoint is still available to the reconnecting process.
  • You need Puppeteer to keep controlling the browser: Do not disconnect yet. Disconnecting detaches that Puppeteer client; reconnect using the saved endpoint if you later need to attach again.

Or skip the browser setup

If your goal is simply to capture a website rather than manage a browser lifecycle, ScreenshotNeo provides a screenshot API. One GET request returns an image or PDF; for example, this cURL command saves a WebP screenshot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. An 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.

Sign up free for ScreenshotNeo.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does Puppeteer’s disconnect() close pages?

No. Puppeteer documents that disconnecting leaves the browser process running and does not close its pages.

Can I reconnect after disconnecting?

Yes, if you saved the browser’s WebSocket endpoint and it remains available. Pass it to puppeteer.connect({ browserWSEndpoint }).

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.

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

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. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.