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 →Use puppeteer.connect() to attach Puppeteer to a Chrome browser that is already running and exposing a remote debugging endpoint. Pass its browser WebSocket URL as browserWSEndpoint, or use browserURL to let Puppeteer discover the endpoint. Call browser.disconnect() when you want Puppeteer to detach without closing Chrome.
Connect to an existing browser with its WebSocket endpoint
Install Puppeteer in your Node.js project, start Chrome with remote debugging enabled, and give puppeteer.connect() the browser-level WebSocket endpoint. The example uses the endpoint format documented by Puppeteer; replace it with the actual value from your running browser.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.connect({
browserWSEndpoint: 'ws://127.0.0.1:9222/devtools/browser/REPLACE_WITH_BROWSER_ID',
});
try {
const page = await browser.newPage();
await page.goto('https://example.com');
console.log(await page.title());
} finally {
await browser.disconnect();
}
})();
Use the browser WebSocket endpoint, not a page-specific target URL. The Puppeteer ConnectOptions reference lists browserWSEndpoint and browserURL as supported connection options.
Find the browser’s debugging endpoint
Chrome listening on a known port
For Chrome listening on port 9222 on the same machine, request http://127.0.0.1:9222/json/version. Read the webSocketDebuggerUrl field in the returned JSON and pass that complete value to browserWSEndpoint. The Chrome DevTools Protocol documentation describes this browser endpoint in its protocol documentation.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
Chrome chooses an available port
If Chrome is started with --remote-debugging-port=0, it selects an available port. Chrome writes the chosen port and browser WebSocket path to the DevToolsActivePort file in the browser profile directory. Use that information to locate the browser endpoint rather than guessing the port. See the Chrome DevTools Protocol documentation.
Use Puppeteer’s browser URL discovery
When you know the debugging server’s HTTP address, but do not want to retrieve its WebSocket URL yourself, use browserURL:
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
const puppeteer = require('puppeteer');
const browser = await puppeteer.connect({
browserURL: 'http://127.0.0.1:9222',
});
The browser must still be running and expose remote debugging. Consult Puppeteer’s connection options for the current option definitions.
Reconnect to a browser launched by Puppeteer
If your application launched the browser with Puppeteer, save browser.wsEndpoint() before disconnecting. You can later pass that endpoint to a new puppeteer.connect() call:
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 →Rank #3
const puppeteer = require('puppeteer');
(async () => {
const launched = await puppeteer.launch();
const browserWSEndpoint = launched.wsEndpoint();
await launched.disconnect();
const browser = await puppeteer.connect({ browserWSEndpoint });
const pages = await browser.pages();
console.log(`Connected; open pages: ${pages.length}`);
await browser.disconnect();
})();
Puppeteer documents this launch, save, disconnect, and reconnect flow in its browser management guide. The endpoint has the form ws://HOST:PORT/devtools/browser/<id>.
Disconnect Puppeteer without closing Chrome
Choose the lifecycle method based on whether the browser should remain available after your script finishes.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
| Call | Effect | Use it when |
|---|---|---|
await browser.disconnect() |
Detaches Puppeteer; the browser and its pages stay open. | A person or another automation step should keep using the session. |
await browser.close() |
Closes the browser. | Your task is finished and Chrome should shut down. |
Puppeteer’s browser management guide explicitly distinguishes disconnect() from close(): disconnecting does not shut down the browser or close its pages.
Protect the session you attach to
An existing Chrome session can contain signed-in accounts, cookies, and other active session data. Chrome warns that a connected agent inherits that data in its remote-debugging guidance. Treat the debugging endpoint as sensitive access:
Best Value
- Keep the debugging port limited to trusted local processes where possible; do not expose it to an untrusted network.
- Use a dedicated browser profile for automation when practical, rather than attaching to a personal profile.
- Only connect software and agents you trust, since the connection can act within the active session.
Troubleshoot connection failures
- Connection refused or timeout: Chrome may not be running, remote debugging may not be enabled, or Puppeteer may be using the wrong host or port. Confirm that
http://127.0.0.1:9222/json/versionresponds when using port 9222, or check the port Chrome selected. - Invalid or rejected WebSocket endpoint: retrieve the complete
webSocketDebuggerUrlfrom/json/versionor use the endpoint returned bybrowser.wsEndpoint(). Ensure it is the browser endpoint, not a page target. - Browser closes unexpectedly: check that the code calling
browser.close()is not being used when you intend to detach. Usebrowser.disconnect()to leave Chrome running. - Session unexpectedly has account access: this is expected when attaching to a profile that is already signed in. Disconnect, then switch to a dedicated profile and restrict access to the debugging endpoint.
Or skip the browser setup
If your goal is a website screenshot rather than controlling a live Chrome session, ScreenshotNeo returns an image or PDF from one GET request. Its API documentation is at screenshotneo.com/docs/.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. It also provides an MCP server for AI agents, and includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
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.

