Back to Knowledge Hub
Getting Started

Chrome Remote Debugging Port: What It Exposes

Separate the flag, the HTTP discovery endpoints and the CDP socket before reading a refused connection as a broken flag. Measured on one owned Chromium launch.

BotBrowser Team

Documentation

Want the structured docs for Getting Started?

This article lives in the editorial library. For step-by-step setup, reference material, and ongoing updates, jump into the docs section.

One Chromium launch with the debugging flag answers /json/version and /json/list on localhost; connectOverCDP reuses the running browser; a launch without the flag is refused and a busy profile aborts.

A connection refused on the debugging port does not mean the flag failed, and a working flag does not mean only your test can reach the browser. "chrome remote debugging port" hides three separate layers that fail in three separate ways: the command-line flag that asks Chromium to listen, the HTTP discovery endpoints that answer on that port, and the CDP socket that carries the actual protocol traffic. A launch that never received the flag has nothing listening, so the connection is refused. A launch that did receive the flag exposes an unauthenticated control surface to anything on the machine that can open a connection to it.

The owned run below starts one stock Chromium build with the flag, reads both discovery endpoints over 127.0.0.1, and attaches with connectOverCDP to record exactly what an attachment sees. The same run records the two failures a reader meets most often: a launch without the flag, and a second launch pointed at a profile directory that is already in use. The BotBrowser launcher guide documents a real Chromium binary launch, so documented Chromium flags including the debugging port behave as documented; BotBrowser does not gate or authenticate the port, so anything that can reach it on the machine can drive the browser, and use stays on owned machines.

TL;DR

  • The flag asks Chromium to open a listening socket on localhost. No flag, no listener: the owned run recorded ECONNREFUSED on a port that never received one.
  • /json/version answered 200 with the browser build and protocol version; /json/list enumerated the running targets, including the open page.
  • chromium.connectOverCDP('http://127.0.0.1:PORT') attached to the existing browser, saw one context and the open page, and could navigate that page.
  • The attachment reuses the running browser instead of launching a new one; what it sees is the live target list, not a fresh instance.
  • A second launch pointed at a user data dir already in use aborted with a ProcessSingleton failure and exit code 21; the port never started listening.
  • BotBrowser starts a real Chromium binary, so the flag behaves as documented; it does not add authentication to the port or restrict who can attach.

Table of contents

The DevTools MCP versus Playwright MCP article compares two control surfaces that both attach to this port. The Playwright executable path page owns which Chromium binary starts in a managed launch. What follows starts from a binary the operator launched manually with the flag.

Separate the flag, the endpoint and the socket

The Chrome remote debugging documentation describes the flag and the discovery page; the DevTools protocol overview describes the socket protocol itself. Each layer answers a different question, and conflating them is what turns "the port is closed" into a wrong diagnosis:

LayerWhat starts itWhat it answersHow it fails
The command-line flagThe operator or the launcherWhether Chromium was asked to listen at allAbsent from the command line: nothing listens
HTTP discovery endpointThe listening socketWhich browser build, protocol and targets are liveFlag present but socket unreachable: still refused
CDP socketThe discovery handshakeThe actual control channel for automationEndpoint answers but protocol traffic does not flow

The flag does not authenticate anything. It does not check who connects, and it does not distinguish your test process from any other process on the machine. The discovery endpoints are plain HTTP GET requests that answer with JSON. The CDP socket is the WebSocket URL inside that JSON, and every automation tool that "attaches to Chrome" ultimately speaks through it. Reading the three layers separately turns a vague "the port is not working" into one of three specific observations: nothing listens, the endpoints answer but automation cannot drive the browser, or automation drives the browser you did not mean to control.

What the owned run measured

The owned fixture launched one installed stock Chrome build, version 158.0.8127.89, headless, with --remote-debugging-port bound to a free port on 127.0.0.1. It then issued HTTP GET requests to /json/version and /json/list, attached with chromium.connectOverCDP to the same port, and recorded what the attachment observed. A second case repeated the connection attempt against a port that never received the flag, and a third case pointed a second raw Chrome process at the same user data dir as a running first instance. No third-party request was made; all traffic stayed on 127.0.0.1.

The fixture prints a one-line summary of the three case outcomes to stdout; that line is:

{"status":"passed","cases":[{"case":"flag-discovery-attach","status":"passed"},{"case":"no-flag-port-refused","status":"passed"},{"case":"busy-user-data-dir","status":"passed"}]}

The measured record from docs/evidence/chrome-remote-debugging-port-what-it-exposes-run-20261125.json is:

CaseMeasured observationFinal state
Flag and discovery/json/version answered 200 with Chrome/158.0.8127.89 and protocol 1.3; /json/list answered 200 with two targets, types page and browser_ui, including the open about:blank pageDiscovery endpoints live
Attach over CDPconnectOverCDP saw one context and one page (about:blank); a navigation issued through the attachment was read back from the same pageAttachment reuses the browser
No flagA connect attempt on a port that never received the flag failed with ECONNREFUSEDNothing listens
Busy user data dirThe second raw Chrome process aborted with a ProcessSingleton failure, exit code 21; the port never listenedLaunch changes, nothing starts

The /json/version body carried the browser build Chrome/158.0.8127.89, the protocol version 1.3, a HeadlessChrome user agent, and the WebSocket URL ws://127.0.0.1:PORT/devtools/browser/<uuid>. The /json/list body enumerated two targets at the moment of the call: the open page target and a browser_ui target. Target counts and target URLs change between runs and between moments of the same run; the record keeps what was live at call time.

const cdp = await chromium.connectOverCDP('http://127.0.0.1:51800');

cdp.contexts().length; // 1: the running browser's context, not a new one
cdp.contexts()[0].pages(); // the live pages, including about:blank

// The attachment drives the same page a manual operator would see:
await cdp.contexts()[0].pages()[0].goto('data:text/html,attached-from-cdp');

connectOverCDP attaches to the browser the port belongs to. It does not launch a new Chromium, it does not create a second browser process, and the context it exposes is the context the running browser already had. A navigation issued through the attachment is visible to anything else observing that page, and vice versa. The owned run navigated the attached page to a data: URL and read the URL back through the same handle, which is the smallest observable proof that the attachment and the page share one target.

/json/version and /json/list enumerate the running browser

The two GET endpoints are the cheapest health check the port offers. /json/version answers with the build identity, the protocol version, and the browser-level WebSocket URL; /json/list answers with the current target list. In the owned run both answered 200 while the browser that owned the socket was still running; the record keeps the call results, not a timing measurement of when listening began. A reader who sees ECONNREFUSED has a listener problem; a reader who sees the endpoints answer has a listener but may still have a protocol problem, and those are different diagnoses with different next steps.

The target list is a snapshot, not a registry. The owned run recorded two targets for a browser with one open page because Chromium maintains additional targets beyond page targets; the types observed were page and browser_ui. Another run with a different page count records a different list. A test that asserts on a specific target count is asserting on a moment, and a reader who treats a target URL from /json/list as a stable identifier will watch it change under them. The same caution applies to the browser UUID inside the WebSocket URL: it identifies the running instance, not the installation.

connectOverCDP attaches instead of launching

The distinction matters for everything downstream: the attachment does not get a fresh profile, a fresh context, or a fresh process. The Playwright connectOverCDP reference documents the call; the owned run adds the observation that the attachment saw one context and the already-open page, and that the context's page list included the page the fixture had opened before attaching. A test that attaches and then asserts on "the" page list is asserting on whatever the running browser had open at attach time.

The attachment also holds real control. The navigation the fixture issued through the attached handle changed the page the original browser owned. That is the point of the port, and it is also the reason the port's exposure matters: the same reach works for any process on the machine, not just the test that attached first.

The lifetime of the attachment is worth naming too. The attachment is a client of the socket, not the owner of the browser: the browser process the flag started is the service, and the attachment ends when the client disconnects or when the browser exits, whichever comes first. There is no separate server to survive the browser, and the fixture closed its attachment before closing the launch it had created. A test that treats the attachment as a session and the browser as an independent service will misread both lifetimes; they are one lifetime observed from two sides.

The refused connection and the busy profile

The two failure cases answer the two most common misdiagnoses. The first: a connection refused on the debugging port, with the flag believed present. The owned run recorded ECONNREFUSED against a port that never received the flag, which is what a launch without the flag produces. A refused connection means nothing is listening; it does not mean the flag was rejected, malformed, or ignored. The next observation is the command line of the running browser, not a retry loop.

The second: a second launch pointed at a user data dir that a running browser already holds. The owned run's first instance was launched through launchPersistentContext without the flag; the second attempt was the raw Chrome binary with the same user data dir and the flag. Chromium aborted the second process with a ProcessSingleton failure and exit code 21, and the port never started listening. The profile directory is the lock; a busy profile changes what launches before any flag has a chance to matter. The record keeps the exact stderr line, so a reader can compare their own abort text against it.

What the port exposes and who can reach it

Everything the port exposes lives on the machine that runs the browser. The discovery endpoints answer on the host and port the flag named; in the owned run that was 127.0.0.1 on a port chosen at launch time. The WebSocket URL inside /json/version names the same host and carries a browser UUID. Any process that can open a connection to that host and port can read the endpoints, obtain the WebSocket URL, and drive the browser. There is no authentication step between a TCP connect and full protocol control.

That scope is the reason the run stays on 127.0.0.1. Binding to localhost keeps the surface inside the machine; it does not make the port safe to share beyond the machine, and the record does not claim that. The port also does not sandbox who attaches: a test, a monitoring process, and anything else on the host all see the same unauthenticated endpoint. The practical rule the record supports is narrow: use the flag on owned machines, for owned automation, and treat a listening debugging port as full browser control available to the host's other processes.

The target list deserves the same narrowing. The /json/list URLs identify targets at a moment; they are not stable handles, and the record does not claim they are. Automation that needs a durable handle creates its own pages and keeps its own references instead of re-reading the list.

BotBrowser capability and limitation

BotBrowser's launcher guide documents how a real Chromium binary starts with a profile, and the Playwright setup page documents the managed launch path. A real binary means documented Chromium flags, including the debugging port, behave as their documentation says. The DevTools protocol overview describes what flows over the socket once it is open.

The limitation sits in the same paragraph: BotBrowser does not gate or authenticate the debugging port, and it does not change what the port exposes. A BotBrowser profile makes the browser surface repeatable; it does not add a credential check to the discovery endpoints, and it does not restrict which local process can attach. Everything above about exposure and machine-local scope applies to a BotBrowser launch exactly as it applies to a stock Chromium launch.

FAQ

Why is my connection refused when I set the flag?

The owned run recorded ECONNREFUSED only for the case where nothing listened. Confirm the flag is on the command line of the process that is actually running, and confirm the port you connect to is the port the flag named. A launch that reuses an already-busy user data dir aborts before listening, which also produces a refused connection.

What do /json/version and /json/list expose?

/json/version exposes the browser build, the protocol version, and the browser-level WebSocket URL. /json/list exposes the current target list, including open pages with their URLs. In the owned run the version call answered with Chrome/158.0.8127.89 and protocol 1.3, and the list call answered with two targets for a browser holding one open page.

Does connectOverCDP launch a new browser?

No. The owned run attached to the existing browser and saw one context and the already-open page. The attachment drives the live browser; it does not create a second process or a fresh profile.

Is the debugging port safe to expose?

The record does not claim that. Everything recorded ran on 127.0.0.1. Any process that can reach the host and port can read the endpoints and drive the browser; the port has no authentication. Keep it on owned machines.

What happens when the user data dir is already in use?

The owned run's second process aborted with a ProcessSingleton failure and exit code 21 before listening on any port. The profile directory is held by the first browser; a second launch with the same profile does not start a second debuggable browser.

Sources

Practical conclusion

The flag asks Chromium to listen, the discovery endpoints answer on that socket, and the CDP socket carries the protocol. Read them separately: ECONNREFUSED means nothing is listening, /json/version and /json/list confirm what is live, and connectOverCDP reuses the running browser instead of starting a new one. The owned run recorded all four facts in one launch: 200 on both endpoints, one context and one live page through the attachment, ECONNREFUSED without the flag, and a ProcessSingleton abort with exit code 21 on a busy profile. The port is unauthenticated control of the browser for anything on the machine; BotBrowser starts the real binary and does not change that. Keep the launch owned, keep the port local, and keep the target list a snapshot rather than a registry.

#Chrome Remote Debugging Port#Devtools Protocol#connectOverCDP#Json Version#Json List

This article is part of the guide: Browser Automation Getting Started: A First Run Map

Run the same check in BotBrowser

Load a profile, keep the signals you just read about consistent inside the browser, and confirm the result on your own machine before a rollout.