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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use two different endpoints: connect Selenium to the remote machine through the Grid URL, then connect browser-level tools to Chrome’s own remote-debugging address. A Grid page such as http://grid-host:4444 reports Grid status; it is not automatically the DevTools page for a headless tab. Selenium’s JavaScript Chromium API documents a debugger address such as localhost:9222, but the address must be enabled on the Chrome process and reachable from the process that uses it.

Which “debugging page” do you mean?

Remote Selenium deployments expose several services. Choose the one that matches the task before changing ports or firewall rules.

Need Endpoint or tool What it shows
Check that Selenium Grid is running, inspect nodes and slots, or view session state Grid server URL, for example http://localhost:4444, and its /status endpoint Grid-level deployment and session information, not a Chrome DevTools target. Selenium documents port 4444 as the default for a local standalone Grid. Selenium Grid documentation
Inspect a particular Chrome tab, console, network activity or runtime errors Chrome’s remote-debugging service and a compatible DevTools frontend Browser-level targets. The exact URL, target discovery path and exposure method depend on how Chrome was launched.
Drive the browser with WebDriver RemoteWebDriver pointed at the Grid URL WebDriver commands executed by a browser on the remote host. Remote WebDriver documentation

If you open the Grid address expecting Chrome’s inspector, you will see Grid UI or status instead. If you use localhost:9222 from your laptop while Chrome is inside another host or container, you will reach your laptop, not the browser machine.

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

Network model: client, Grid and Chrome

A typical setup has at least three hops:

  1. Your test process creates a RemoteWebDriver session at a Grid URL.
  2. The Grid routes commands to a node where Chrome and ChromeDriver run.
  3. If you attach browser-level debugging, your debugging client must also reach Chrome’s configured debugging port on the machine or network namespace where Chrome runs.

Use a routable host name or IP for each hop. localhost only means “the machine running this process”; in Docker, it normally means the current container. In a distributed Grid, Hub, node and browser ports may require separate routing rules. Do not expose a debugging port to the public internet merely to make it convenient: the supplied Selenium documentation does not define a universal authentication, TLS, tunnel or firewall recipe for every deployment.

Start a remote headless session through Selenium Grid

First start or obtain a Grid on the host that runs Chrome. Standalone Grid is Selenium’s simplest single-machine topology; Hub/Node and distributed topologies are intended for multiple machines, browser versions or operating systems. Selenium’s getting-started material lists Java 11 or newer, a browser and a driver among the prerequisites, and Selenium Manager can configure drivers when enabled. In all topologies, make the Grid URL reachable from the client.

Java example

This illustrative pattern creates a headless Chrome session on a remote Grid. Replace the URL with the address visible from your test process.

import java.net.URL;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;

public class RemoteHeadless {
  public static void main(String[] args) throws Exception {
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--headless=new");
    WebDriver driver = new RemoteWebDriver(
        new URL("http://grid-host:4444"), options);
    try {
      driver.get("https://example.com");
      System.out.println(driver.getTitle());
    } finally {
      driver.quit();
    }
  }
}

The --headless=new argument is an example of Chrome’s headless option, not proof that a DevTools frontend is exposed. Keep Chrome and ChromeDriver major versions aligned; Selenium calls out matching major versions as a Chrome requirement. See Chrome-specific functionality.

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

JavaScript example with the Grid URL

With the Selenium JavaScript package, the Grid endpoint belongs in Builder().usingServer(). It is independent of any Chrome debugger address.

const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

(async () => {
  const options = new chrome.Options();
  options.addArguments('--headless=new');
  const driver = await new Builder()
    .forBrowser('chrome')
    .setChromeOptions(options)
    .usingServer('http://grid-host:4444')
    .build();
  try {
    await driver.get('https://example.com');
    console.log(await driver.getTitle());
  } finally {
    await driver.quit();
  }
})();

Attach to Chrome’s remote-debugging address

Attaching is a separate operation. Chrome must already be running with remote debugging enabled, and the debugging port must be reachable from the process making the attachment. The supplied Selenium JavaScript API documents the Chromium option debuggerAddress in the form hostname|IP:port, using localhost:9222 as its example. Its API reference is at chromium.js.

JavaScript attachment pattern

const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

(async () => {
  const options = new chrome.Options();
  options.debuggerAddress('browser-host:9222');
  const driver = await new Builder()
    .forBrowser('chrome')
    .setChromeOptions(options)
    .build();
  try {
    console.log(await driver.getTitle());
  } finally {
    await driver.quit();
  }
})();

Use the documented localhost:9222 value only when the Selenium process and Chrome share that network location. For a browser on another host, substitute a reachable address. The exact Chrome launch command, DevTools target URL, tunneling method and authentication policy vary by bare-metal, container and hosted-browser deployments; verify those details with the operator of the target environment instead of assuming that one URL will always open the desired tab.

Do not confuse attachment with a new Grid session

A normal RemoteWebDriver call asks Grid to create and route a session. A debugger address points at an already configured Chromium debugging server. Depending on the binding and deployment, combining both concepts may not be supported in the way you expect. Decide whether you need Grid-managed session creation or attachment to an existing Chrome process, and follow the binding’s documented API for that mode.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Opening a usable DevTools view

Once the debugging service is reachable, use a DevTools-compatible frontend and the target information returned by that service. Selenium’s documentation does not establish one universal browser URL, target-selection flow or secure remote exposure recipe. In practice, validate connectivity from the same network namespace as the client, confirm that the expected target exists, and keep the debugging endpoint private or behind an authenticated tunnel controlled by your deployment.

Headless mode does not create a visible desktop window. “Opening the debugging page” therefore means opening a DevTools frontend connected to the remote target, not displaying the headless browser itself. If your goal is only a visual record of the rendered page, a screenshot service can be simpler than forwarding DevTools.

CDP or WebDriver BiDi?

Chrome DevTools Protocol (CDP) is Chrome-specific and version-sensitive. Selenium describes its CDP support as temporary while WebDriver BiDi is implemented, and notes that available CDP features depend heavily on the browser version. Use CDP when you specifically need Chrome DevTools domains such as console or network events and have verified the Selenium binding and Chrome version. For cross-browser, standards-oriented event streaming, evaluate WebDriver BiDi; Selenium presents BiDi as the direction for a stable cross-browser API. Read Selenium’s CDP documentation and the WebDriver documentation for the current binding support.

Deployment choices before you expose a port

Topology Best fit Operational implications
Standalone Grid One machine for development or a small controlled job Easiest Grid setup; default local endpoint is port 4444.
Hub/Node Several machines or distinct browser and operating-system environments Central routing with separately managed nodes and network paths.
Distributed Grid Independent scaling of Grid components More component endpoints and routing to operate; plan CPU, memory and parallel-session capacity.

Choose the topology first, then document which process can reach the Grid endpoint and which can reach Chrome’s debugger endpoint. A port that is reachable from the test runner may still be unreachable from your desktop, and vice versa.

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

Troubleshooting remote headless debugging

The page shows Grid status, not DevTools

Cause: you opened the Grid URL, commonly port 4444. Fix: use that URL only for Grid health and sessions; configure and reach Chrome’s separate debugger address.

localhost:9222 refuses the connection

Cause: Chrome is not listening on that port, the port is bound inside another container or host, or a firewall blocks the route. Fix: verify Chrome’s launch configuration and test the address from the same machine or namespace as the attaching process. Do not “fix” it by publishing an unauthenticated port publicly.

The Grid session cannot be created

Cause: the client cannot route to the Grid host, the Grid has no matching slot, or browser/driver prerequisites are missing. Fix: use a host name resolvable by the client, inspect Grid status, confirm node capacity and check that Chrome and ChromeDriver major versions match.

The browser opens but CDP commands fail

Cause: CDP support is tied to Chrome and Selenium versions and is not a stable cross-browser testing API. Fix: verify the binding’s supported CDP version, update compatible components, or redesign the feature around WebDriver BiDi where available.

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

The wrong tab or no target appears

Cause: the debugging service exposes multiple targets or the expected page has not loaded. Fix: inspect the targets reported by the debugging service, wait for navigation in WebDriver, and select the intended target using the mechanisms supported by your chosen DevTools frontend.

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

Or skip the browser setup

If you need a rendered image or PDF rather than interactive DevTools, ScreenshotNeo provides a single-call website screenshot API and MCP server. It removes cookie/consent banners, newsletter popups and chat widgets before capture; bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP tools—take_screenshot, get_page_info and capture_pdf—let Claude, Cursor and other MCP clients request captures without you maintaining a browser debugging route.

See the complete parameter reference in the ScreenshotNeo documentation. A GET request returns PNG, JPEG, WebP or PDF according to the options you send:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

You can still control capture details—full-page lazy-image loading, CSS-selector element capture, dark mode, device presets, viewport and retina scale, PDF paper settings and page ranges, custom CSS or JavaScript, clicks, waits, blocked requests, headers, cookies, user agent, authorization, timezone, geolocation, transparency, resizing, chosen cache TTL, signed image links, asynchronous webhooks and bulk capture of up to 100 URLs per call. Every feature is included on every plan. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

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

Frequently Asked Questions

Can Selenium’s Grid URL be used as Chrome’s debugger address?

No. The Grid URL creates and manages WebDriver sessions; Chrome’s debugger address belongs to the browser process and must be configured separately.

Does headless Chrome require a visible desktop or VNC session?

No. Headless Chrome runs without a desktop window. DevTools access is a network and protocol connection to its debugging service, not a requirement for a visible monitor.

Is CDP suitable for a long-term cross-browser test API?

Selenium describes CDP as Chrome-specific, version-dependent and temporary while WebDriver BiDi is implemented. Check current binding support before committing to CDP.

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.