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

puppeteer.connect() attaches Puppeteer to a browser that is already running and returns a Browser object. Use browserWSEndpoint when you have the browser’s DevTools WebSocket URL, or browserURL when you have its debugging HTTP address. Unlike launch(), connect() does not start the browser process.

This guide follows the Puppeteer 25.12.0 API reference, checked October 3, 2026. Defaults and experimental options can change; confirm the reference for your installed version.

How to connect Puppeteer to an existing browser

In Node.js, import Puppeteer, supply a connection target, and await the returned Browser. The following example uses a WebSocket endpoint stored in an environment variable so the endpoint is not hard-coded into the script.

  1. Start or obtain access to a browser that exposes a DevTools connection. Use the browser host and endpoint supplied by your deployment or browser provider.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    #1 Best Overall
    Search+ For Google
    • google search
    • google map
    • google plus
    • youtube music
    • youtube
  2. Set PUPPETEER_WS_ENDPOINT to the complete WebSocket URL, such as ws://HOST:PORT/devtools/browser/<id>. Use the actual endpoint, not the illustrative host or ID.

  3. Run this script with Puppeteer installed in the Node.js project:

    import puppeteer from 'puppeteer';
    
    const browserWSEndpoint = process.env.PUPPETEER_WS_ENDPOINT;
    if (!browserWSEndpoint) {
      throw new Error('Set PUPPETEER_WS_ENDPOINT to the browser WebSocket URL');
    }
    
    const browser = await puppeteer.connect({ browserWSEndpoint });
    try {
      const page = await browser.newPage();
      await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
      console.log(await page.title());
    } finally {
      await browser.disconnect();
    }

    disconnect() ends Puppeteer’s connection without asking it to close the browser process. That distinction matters when the browser is managed separately or shared. Use the appropriate browser-management mechanism if you intend to shut down the process.

The official PuppeteerNode.connect() reference describes the method as attaching Puppeteer to an existing browser instance. It resolves to a Browser.

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

Use a debugging HTTP address instead

If your provider gives you the browser’s debugging HTTP address rather than a WebSocket URL, pass it as browserURL:

const browser = await puppeteer.connect({ browserURL: 'http://HOST:PORT' });

Replace the example with the exact debugging address documented by the browser host. The API reference lists both target options; the endpoint format and discovery method are described in the Browser.wsEndpoint() reference.

Rank #2
Google Search
  • Google search engine.

Where to get browserWSEndpoint

Ask the browser provider or inspect its debugging endpoint

A connected browser’s browser.wsEndpoint() returns its WebSocket endpoint. The documented shape is ws://HOST:PORT/devtools/browser/<id>. If you can access the browser’s debugging HTTP endpoint, request http://HOST:PORT/json/version and read the webSocketDebuggerUrl field from the response. Use the host, port, scheme, and full path as provided; a page-level WebSocket URL is not interchangeable with the browser-level endpoint.

For remote browsers, the debugging address may be private, authenticated, or exposed through a provider-specific proxy. Follow that provider’s instructions for network access and authentication rather than assuming a local Chrome port is reachable from your Node process.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Connect or launch: which method should you use?

Question connect() launch()
What happens? Attaches to an already-running browser and returns a Browser. Starts a browser process under Puppeteer’s control.
What must you provide? A connection target such as browserWSEndpoint or browserURL. Launch configuration; launch-specific options extend the shared connection options.
Typical fit A hosted, remote, shared, or separately managed browser. A browser process that your script should start and manage.

The current LaunchOptions reference says launch options extend ConnectOptions with launch-specific settings. A connection option such as defaultViewport can therefore matter in both workflows, but only connect() attaches to an existing instance.

ConnectOptions that matter most

The options below reflect Puppeteer’s 25.12.0 reference. An option described as experimental, deprecated, or runtime-specific should not be treated as a stable cross-browser setting.

Connection target: browserWSEndpoint, browserURL, transport, and channel

Viewport, timing, and target selection

Protocol selection and capabilities

The current reference documents CDP as the default protocol for Chrome launch and browser connections, and WebDriver BiDi as the default for Firefox launch. The capabilities option applies only when using protocol: 'webDriverBiDi' with Puppeteer.connect(). Check the browser and Puppeteer support for the protocol you select instead of assuming CDP-only features work under BiDi or vice versa.

Headers and WebSocket options

headers is deprecated. In Node.js, pass WebSocket connection headers through wsOptions.headers instead:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const browser = await puppeteer.connect({
  browserWSEndpoint: process.env.PUPPETEER_WS_ENDPOINT,
  wsOptions: {
    headers: {
      Authorization: `Bearer ${process.env.BROWSER_TOKEN}`,
    },
  },
});

Do not put secrets directly in source code or logs. If the browser host expects credentials in a different form, use its documented connection method. The API reference specifies that wsOptions is Node.js-only; WebSocket keep-alive settings are ignored in browser builds because those builds lack the ping-frame API. If both deprecated headers and wsOptions.headers are supplied, wsOptions.headers takes precedence.

Experimental network controls and event settings

Other behavior options

  • acceptInsecureCerts controls whether HTTPS errors are ignored during navigation; the documented default is false.

  • handleDevToolsAsPage controls whether DevTools windows are treated as Puppeteer pages; the documented default is false.

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

Common connection problems and fixes

Symptom Likely cause What to check
Connection fails immediately The endpoint is mistyped, stale, inaccessible, or not a browser-level DevTools endpoint. Confirm the full WebSocket URL or debugging HTTP address with the browser host. For a reachable debugging endpoint, inspect /json/version and its webSocketDebuggerUrl.
Local connection works but remote connection fails The Node process cannot reach the remote host or the provider requires a proxy, authentication, or a specific network route. Check the provider’s endpoint and access requirements, firewall or network policy, and any required Node.js WebSocket headers.
Authentication or upgrade is rejected Credentials may be missing, malformed, or passed through the deprecated option. For Node.js WebSocket headers, use wsOptions.headers and verify the credential format expected by the browser host.
Navigation or protocol calls time out The browser or page is slow, unreachable, or waiting on work that does not finish within the per-call timeout. Check browser health and network access first; then consider whether protocolTimeout is appropriate for the affected call.
Page dimensions differ from the browser window Puppeteer applies its default viewport to pages. Set an explicit defaultViewport, or use null to avoid applying the default viewport.
Features stop working after network monitoring is disabled A feature may rely on request or response events. Keep networkEnabled enabled when the workflow needs HTTPRequest or HTTPResponse events.
A browser option appears ignored The option may be experimental, browser-specific, Node-only, or unsupported by the selected protocol. Compare the option’s scope in the 25.12.0 reference with your browser, runtime, and protocol.

Performance, reliability, and cost considerations

connect() reuses a browser process instead of starting one, which can fit environments that already manage browser lifecycle. It does not by itself guarantee a faster or more reliable workflow: connection latency, browser capacity, page load behavior, endpoint stability, and provider limits remain environment-dependent. The API reference does not establish general performance or cost figures.

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

For a shared browser, be deliberate about which targets your script can see and what state it changes. Disconnect when the work is complete, and follow the owner’s lifecycle rules so your script does not close or disrupt a browser used by another task.

Or skip the browser setup:

If your goal is a website screenshot rather than browser automation, ScreenshotNeo provides a screenshot API and MCP server. One GET request returns an image or PDF; see the 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 removes cookie/consent banners, newsletter popups, and chat widgets before the shot. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.

Frequently asked questions

What is the difference between browserWSEndpoint and browserURL?

browserWSEndpoint takes the browser’s DevTools WebSocket URL; browserURL takes its debugging HTTP address. Choose the one your browser environment exposes.

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

Can I use Puppeteer connect in a browser build?

Some connection options are runtime-specific. In particular, the reference limits wsOptions to Node.js and says keep-alive settings are ignored in browser builds.

Does connect close the browser when I am done?

Use browser.disconnect() to detach Puppeteer while leaving the independently managed browser running. Browser process shutdown is a separate lifecycle decision.

Quick Recap

Bestseller No. 1
Search+ For Google
Search+ For Google
google search; google map; google plus; youtube music; youtube; gmail
Bestseller No. 2
Google Search
Google Search
Google search engine.
Bestseller No. 3
Search+ for Google
Search+ for Google
Voice search enabled; Clean and simple to use; Max speed and compatibility for your Kindle device
Bestseller No. 4

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.