Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To attach Selenium to an already running headless Chrome, start Chrome with a remote DevTools debugging port, then give that host and port to ChromeDriver through the debuggerAddress option. A local example is:
chrome --headless=new --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug https://example.com
Then connect from Selenium:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Chrome(options=options)
print(driver.title)
driver.quit()
What the attachment actually does
Normally, webdriver.Chrome() asks ChromeDriver to launch a new Chrome process. With debuggerAddress, Chrome is launched separately and ChromeDriver connects to the DevTools server exposed by that process. ChromeDriver documents the capability as a debugger server address in hostname/ip:port form, such as 127.0.0.1:38947. Selenium’s Chromium options API calls the equivalent property debugger_address and requires a string.
This is useful when another process has already prepared a page, profile, extension, cookies or network state. It is not equivalent to a fully fresh Selenium session: ChromeDriver’s automation extension is loaded at startup, and it is absent when you attach to an existing process. Commands that depend on that extension can therefore fail.
Prerequisites and a safe launch
- Chrome or Chromium installed on the machine running the browser.
- A compatible ChromeDriver/Selenium installation. Keep Chrome and ChromeDriver versions aligned, especially after browser updates.
- A separate user-data directory for the debug process. Do not point a test instance at the profile used by an ordinary Chrome process.
- A reachable debugging host and port. Keep the endpoint on a trusted interface unless you have separately secured it.
For a simple local session, use a fixed port:
chrome --headless=new
--remote-debugging-port=9222
--user-data-dir=/tmp/chrome-debug
https://example.com
The --headless=new flag selects Chrome’s current headless implementation in documentation that uses this example. Command-line behavior is version-sensitive, so verify the flags supported by the Chrome binary installed in your environment.
#1 Best Overall
- ❤Console cable❤ :6FT-USB-RS232-RJ45 console cable .It's used for debugging and configuring network equipment ❤!!Please NOTE❤ this is USB to RJ45 CONSOLE CABLE ,Not ETHERNET !!!It is 8p8c!! Look carefully of the Pin is match with your device. Before ordering , please confirm it is you need. After receiving ,please read user manual /instruction at first . Customer service always online.
- ❤Works for console port❤this USB to rj45 console cable Replaces COM port RS232 (DB-25/DB-9) serial port perfectly, connects to any laptop/PC's USB port directly to a console port like a charm. No more RS232 Female and male adapters。32 and 64 bit operating systems are both support.except Chrome OS
- ❤Essential tools for network engineers❤The Cisoc Console Cable It's designed for that a PC or laptop‘s USB port connect to the console port with their Cisco modem, router, firewall, switch or other Serial based Cisco device. Cisco,Juniper,NETGEAR,Ubiquity,LINKSYS,TP-Link ,huawei, H3C, HP, 3com compatibly.
- ❤The pinout names❤Cisco usb console cable USB2.0 (1.1 compatible); CONSOLE's DTE Pinouts: RTS(1), DTR(2), TXD (3), GND(4), GND(5), RXD (6), DSR(7), CTS(8); the RJ45 pinout names is 1-CTS, 2-DSR, 3-RXD, 4-GND, 5-GND, 6-TXD, 7-DTR, 8-RTS. Cable length 1.8m/6ft, Maximum RS232 speed 500kbaud
- ❤LIFETIME CUSTOMER SUPPORT❤beside get 1pack *6ft cisco usb to console,you also back with 180-day no reason free return and refund and 24-hour online service.
Linux, macOS and Windows command details
The flag order is the same on each platform; only the executable path and data-directory syntax differ. On Windows, for example, invoke the installed chrome.exe with a Windows path such as --user-data-dir=C:tempchrome-debug. The directory must be writable and should not be shared by concurrent browser processes.
Find and verify the DevTools endpoint
A fixed port is convenient for one local session. For parallel jobs, ask Chrome to choose an available port:
chrome --headless=new --remote-debugging-port=0
--user-data-dir=/tmp/chrome-debug
Chrome prints a WebSocket URL when it starts. The DevTools Protocol also exposes browser information at /json/version, including webSocketDebuggerUrl. When Chrome chooses the port, it can write the selected value to a DevToolsActivePort file in the user-data directory.
Recommended Free Tools
Before starting Selenium, check the endpoint from the same machine:
curl http://127.0.0.1:9222/json/version
A working response is JSON describing the browser and its WebSocket debugger URL. If the request is refused, Chrome has not started, the selected port is different, or the endpoint is bound to another interface.
Rank #2
- !!Please NOTE: this is MALE RS232 to DB9 SERIAL CABLE ,Not VGA!!!It is 9 pin, NOT 15 pin!! Look carefully of the Pin is match with your device. Before ordering , please confirm the interface gender is waht you need. After receiving ,please read user manual /instruction at first and download the Driver at first from FT232 Official website or Cisco website . Customer service always online.
- Wide range of applications: USB to RS232 DB9 male serial adapter can work with your Windows (10 / 8.1 / 8 / 7 / Vista / XP), MAC or Linux system and other platforms. USB adapter is designed to connect to serial devices, such as serial modem with DB9, ISDN terminal adapter, digital camera, label writer, palm computer, barcode scanner, PDA, cash register, CNC, PLC controller, tax printer, POS, bar code scanner, label printer, etc
- High quality: ftdi usb serial,the latest ftdi chip set ensures more reliable and faster operation. USB 2.0 to RS232 male DB9 console cable will support 1Mbps date transfer rate.
- Most convenient: rs232 to usb simple installation, plug and play, COM port creation, baud rate can be changed to the required settings. USB power supply - no external power supply required.
- Exquisite design: usb-to-serial,Gold Plated USB RS232 connector and PVC cable ensure high performance and extra durability. Powered by USB port, this USB to DB9 series RS232 adapter cable is designed to fit easily into your handbag.
Fixed versus ephemeral ports
| Choice | Best for | Trade-off |
|---|---|---|
| Fixed port, such as 9222 | Local tutorials, one long-lived process and simple scripts | Another process may already occupy the port; parallel jobs need coordination |
| Port 0 | Workers that start many independent Chrome sessions | Your launcher must discover and pass the selected port to Selenium |
Connect with Selenium Python
Install Selenium in the environment that will run the client:
python -m pip install -U selenium
Complete example:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import WebDriverException
options = Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
try:
driver = webdriver.Chrome(options=options)
print("Title:", driver.title)
print("URL:", driver.current_url)
driver.quit()
except WebDriverException as exc:
print("Could not attach:", exc)
The value must be a string containing only the debugger host and port, not an HTTP URL and not the WebSocket path. Use localhost:9222 or 127.0.0.1:9222 when Chrome runs locally. If Chrome runs in a container or another machine, use the address reachable from the Selenium process and configure the network accordingly.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Using the Selenium property name
Selenium language bindings expose Chromium options differently. In Python, the portable form is add_experimental_option("debuggerAddress", "127.0.0.1:9222"). The underlying Selenium Chromium options API describes the corresponding property as debugger_address. Follow the naming used by your binding rather than copying Python syntax into Java, C# or JavaScript.
Inspect a running headless page visually
Headless Chrome has no ordinary window, but Chrome DevTools can still show its targets. In a regular Chrome window:
- Open
chrome://inspect. - Click Configure.
- Enter the headless browser’s host and port, for example
127.0.0.1:9222. - Find the target tab and click Inspect.
DevTools then provides a live page view and the usual inspection panels for the remote target. This is useful for checking whether a selector exists, watching console errors and examining network requests while Selenium remains attached.
Rank #3
- FTDI FT232RL IC:Built-in original FTDI FT232RL IC. Supports 5V, 3.3V and 1.8V Logic TTL levels,You can switch Logic levels by jumper
- Protective case: Come with a transparent protective casing, this transparent protective casing to effectively prevent static interference from the hand and prevent unintentional short circuit
- Application:Support EEPROM, Vendor ID re-write, unbrick routers ,program ESP8266 module, interface to GPS modules, flash firmware on hard drive, update transmitter, interface to set top box and other compatible UART interface devices
- Compatibility: This USB to TTL adapter is compatible with Windows 7, 8, 10 and various Linux OS and Mac OS
- Customer Support: DSD TECH provides permanent technical support and 1 year product replacement service for this USB to TTL Adapter.
Programmatic inspection with CDP
Selenium Python exposes driver.execute_cdp_cmd(command, args) for Chrome DevTools Protocol operations. For example, enable network events before navigating:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstalldriver.execute_cdp_cmd("Network.enable", {})
driver.get("https://example.com")
CDP commands and event behavior depend on the Chrome version and protocol domain. Use CDP for browser capabilities that Selenium does not directly expose, but keep ordinary element actions in Selenium where possible.
What may not work after attachment
ChromeDriver states that its automation extension is loaded only when ChromeDriver starts Chrome itself. An attached process does not have that startup extension. As a result, some WebDriver commands can return an error such as operation not supported when using remote debugging. ChromeDriver’s documented example is resizing the browser window.
| Need | Recommended session | Reason |
|---|---|---|
| Reuse an existing page, cookies or profile | Attach with debuggerAddress |
The separately launched browser already owns that state |
| Maximum WebDriver command coverage, including startup-extension features | Let ChromeDriver launch Chrome | The automation extension is installed during startup |
| Low-level network or performance control | Attach or launch, then use CDP where supported | CDP exposes protocol domains independently of ordinary WebDriver calls |
If your test requires a command that fails only in attached mode, remove debuggerAddress, configure the desired Chrome arguments in Options, and create a fresh webdriver.Chrome(options=options) session.
Lifecycle, concurrency and reliability
Wait for Chrome before attaching
Starting a process and immediately constructing WebDriver creates a race. Poll /json/version or the port until it responds, with a finite timeout. Do not retry forever: a bad executable path or invalid profile directory will never become ready.
Rank #4
- FEATURES / POWER SPECS : Extra Long 6 Feet USB 2.0 Type-A Male to Type-B Male Connection Cable / High-Speed Transfer Rates up to 480Mbps 28AWG/2C+26AWG/2C with Error-Free Performance
- COMPATIBILITY: Ideal for connecting your Yamaha Digital Piano, Roland Music Workstation, Donner DEP 10 20 45 DDP-80 88 Key Digital Pianos, Alesis, Korg, Casio Keyboard, AKAI Professional, Arturia KeyLab MiniLab, Midiplus, Nektar Impact, Novation, M-Audio MIDI Controller, Native Drum Controller, Pioneer, Hercules DJControl Inpulse, Numark DJ Mixer, Behringer U-Phoria, PreSonus AudioBox Audio Interface, Microphone, Studio Equipment to a Laptop, Computer (Mac PC) and other devices with a USB-B port
- Also is a good USB Type B replacement cord for devices like Printer, Scanner, Fax, Hard Drive Disk, Server, Keyboard, DAC, Development board, UPS, Digital Camera, Arduino, Silhouette Cameo Cutting Tool Machine, Blue, Brother, Canon i-SENSYS PIXMA SELPHY, CyberPower, Dell, Epson Artisan Expression Home Premium Stylus WorkForce, Fujitsu, HP Deskjet ENVY LaserJet OfficeJet PhotoSmart, IOGEAR, Lexmark, Panasonic, Snowball mic
- SAFETY: Pwr+ cables manufactured with the highest quality materials. CE/FCC/RoHS certified.
- WARRANTY: 30 Days Refund - 24 Months Exchange. PWR+ is WA, USA based company. We are friendly Customer Support Experts
Keep ownership clear
Decide which process closes Chrome. driver.quit() ends the WebDriver connection, but the separately launched Chrome process may need to be terminated by the launcher or a process supervisor. Clean up temporary profiles after the browser exits.
Isolate parallel jobs
Each concurrent browser needs its own user-data directory and debugger port, or a reliable port-discovery mechanism. Reusing either can attach a test to the wrong tab or produce profile-lock errors.
Protect the endpoint
The debugging interface is powerful. Binding it beyond the trusted host can expose browser tabs and control capabilities. Restrict firewall and container networking rules, avoid publishing the port publicly, and use an authenticated or otherwise protected tunnel when remote access is unavoidable.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting attachment failures
“cannot connect to chrome” or connection refused
- Confirm Chrome is still running.
- Check
curl http://HOST:PORT/json/version. - Verify the Selenium process can reach the same host and port, especially across containers.
- Check that another process did not take the fixed port.
“debuggerAddress must be a string”
Pass a value such as "127.0.0.1:9222". Do not pass an integer, a dictionary or the full http:// URL.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesChrome starts but no tab appears in chrome://inspect
Recheck the host and port in Configure, then query /json and /json/version. A browser can expose the endpoint while having no navigable page target if the startup command exited or the tab was closed.
Best Value
- USB-CSD5 for KNX3-KAP2 servo USB debugging cable Data cable Download cable Programming cable Dual chip design Industrial Black 3 Meter
“operation not supported when using remote debugging”
This indicates a command depends on ChromeDriver’s startup automation extension. Use a fresh ChromeDriver-managed session for that operation, or replace it with a supported CDP command when an equivalent exists.
Profile lock or corrupted state
Stop other Chrome processes using the directory and launch with a new, dedicated --user-data-dir. Never run parallel jobs against one normal user profile.
Version mismatch or unexpected flags
Record the Chrome and ChromeDriver versions, update the Selenium binding, and consult the current Chrome headless and ChromeDriver documentation for the installed release. Headless flags and supported behavior can change between versions.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Or skip the browser setup
If your goal is simply to obtain a clean website image rather than drive an existing browser, ScreenshotNeo provides a single screenshot API call. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.
cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
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)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo documentation for the remaining capture options. Every plan includes its features: full-page and element capture, device presets, custom viewport and retina scale, PDF controls, HTML/CSS rendering, JavaScript and CSS injection, clicks, waits, blocking, headers and cookies, geolocation, transparent backgrounds, resizing, configurable caching, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Pricing starts with 1,000 screenshots per month free without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Frequently Asked Questions
Can I attach Selenium to a Chrome process running on another machine?
Yes, if the Selenium process can reach that machine’s DevTools host and port. Treat the debugging endpoint as privileged, restrict network exposure, and use a protected tunnel rather than publishing it openly.
Does attaching preserve the existing tab and cookies?
It connects to the already running browser session, so the existing profile and targets remain available. Use a dedicated profile when you need deterministic test state.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Should I use port 9222 or port 0?
Use a fixed port for a single local process. Use port 0 for concurrent workers, then read the selected port from Chrome’s startup output or the DevToolsActivePort file.
Why does a fresh Selenium session support a command that an attached session rejects?
ChromeDriver loads its automation extension only when it launches Chrome. An attached browser did not receive that startup extension, so some commands are unavailable.
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.

