Selenium With a Logged-In Chrome Profile: Why the Old Trick Fails and What Works Now

10 min read

The old trick was one line: launch Chrome with --remote-debugging-port=9222, point Selenium or Puppeteer at it, and drive the browser you already use every day, cookies and logins included. It's now blocked on the default profile, and the error messages for the workarounds are bad.

Here's the argument up front. If you automate one account, fix this yourself with a dedicated user-data-dir. It's free, it's enough, and no tool beats it. If you automate many persistent identities, the fix multiplies into a small piece of infrastructure: directories, locks, proxies, driver versions. That's the point where a local API starts to replace code you'd otherwise maintain.

Both halves are covered below, including the cases where JustBrowser is the wrong pick.

What actually changed in Chrome

As of November 2026, Chrome's developer blog states that from Chrome 136, --remote-debugging-port and --remote-debugging-pipe are no longer respected when debugging the default Chrome data directory. The switches must be accompanied by --user-data-dir pointing to a non-standard directory. The page puts it this way: "These switches will no longer be respected if attempting to debug the default Chrome data directory." Source: Chrome for Developers.

Read that twice. It doesn't say "debugging is gone." It says the default directory, the one holding your everyday logged-in profile, is off-limits for those switches.

So the symptoms you've likely met:

  • You launch Chrome with the port flag and nothing listens on the port.
  • Selenium starts Chrome and reports the user data directory is already in use. (Your normal Chrome window is holding the lock.)
  • A driver starts, then fails to attach because it doesn't match the browser that's actually running.

Three different errors. One root cause family: you're pointing automation at a profile that was never meant to be shared with a debugger. And none of the three messages says so, which is my main complaint about this whole area.

The free Selenium fix for one account

Create a directory that isn't Chrome's default. Launch with it. Log in once by hand. Done.

With Selenium, switches go through the args parameter. Selenium's Chrome documentation says "The args parameter is for a list of command line switches to be used when starting the browser," and lists --user-data-dir=... among the commonly used args. Source: Selenium docs. That page doesn't mention --profile-directory, so don't assume it's the documented route.

from selenium import webdriver

opts = webdriver.ChromeOptions()
opts.add_argument(r"--user-data-dir=/Users/you/automation/acme-profile")

driver = webdriver.Chrome(options=opts)
driver.get("https://example.com/dashboard")

First run: you log in manually in that window. Every run after: the cookies and storage are still there, because the directory is the profile.

Want to attach to an already-running browser instead? Launch Chrome yourself with both switches:

chrome --remote-debugging-port=9222 --user-data-dir=/Users/you/automation/acme-profile

Then attach Selenium through debuggerAddress set to 127.0.0.1:9222. The non-standard directory is what satisfies Chrome's new rule.

Two cautions that save an afternoon:

  1. Don't copy your daily profile into the new directory and expect it to behave. Log in fresh. Copied profiles carry lock files and state that fight you.
  2. One Chrome process per directory. A second launch against the same directory fails or hands off to the running one. That's the "in use" error.

Pick the right browser binary, too

If the job is testing your own app, consider Chrome for Testing. Chrome's documentation describes it as "a Chrome flavor that specifically targets web app testing and automation use cases," a dedicated flavor without auto-update, created purely for automation and testing. Source: Chrome for Testing docs. No auto-update means no surprise browser change between a green run and a red one.

The driver-mismatch trap

Profile errors get the attention. Driver mismatch causes the quiet failures.

Selenium Manager detects the installed Chrome version, then makes a network request to the Chrome for Testing endpoints to discover the proper chromedriver version. It caches that result for one hour before treating it as stale. Source: Selenium Manager docs.

That's helpful when Selenium launches the browser itself. It's less helpful when the browser was started by something else. Selenium Manager sees the Chrome installed on the machine, which may not be the engine your target is actually running. Driver and browser disagree on a major version, and the attach fails with an error that mentions neither.

The rule is simple: the driver's major version must match the browser engine that's actually running, not the one that's merely installed.

Where DIY gets expensive

One account? You've seen the fix. Now count what changes at ten.

Each persistent identity needs:

  • Its own directory, named and tracked somewhere.
  • A lock check, so two jobs don't launch the same profile at once.
  • A proxy per profile, configured the same way every time. (Our ISP proxy setup tutorial covers wiring one in.)
  • A matching driver, pinned per engine.
  • A start and stop routine that doesn't leave orphaned browsers eating memory.
  • A way to hand a script an attach point without hard-coding a port.

None of it is hard. All of it is code you own, and it's tedious code. Honestly, that's the real comparison: not a tool against nothing, but a tool against a profile manager you'll write, debug and keep alive.

Some teams will happily write it. If you've got spare engineering time and two or three profiles, do. If you've got thirty and a deadline, read on.

What the API-based route looks like

JustBrowser is a multi-account browser for teams. Each profile is its own browser with its own cookies, storage and proxy, and a local REST API starts and stops profiles for you.

The facts that matter for this use case, from the docs at justbrowser.app/docs:

  • The API is local. It's bound to 127.0.0.1:36542 (the port is configurable in the app). There is no hosted API.
  • Base URL: http://127.0.0.1:36542/api/v1.
  • Authentication is a Bearer token from the AI page in the app.
  • Responses and errors are enveloped. Branch on error.code, never the message.
  • POST /profiles/{id}/start returns a cdp_url, and starts headless unless the body says {"headless": false}.
  • GET /profiles/{id}/selenium returns a remote_url, a debugger_address and ready-made capabilities.
  • POST /profiles/{id}/stop ends the session. browser.close() only disconnects.

Here's the whole flow:

import requests
from selenium import webdriver

BASE = "http://127.0.0.1:36542/api/v1"
HEADERS = {"Authorization": "Bearer YOUR_TOKEN"}
profile_id = "your-profile-id"

# Visible window; omit the body for headless
requests.post(
    f"{BASE}/profiles/{profile_id}/start",
    headers=HEADERS,
    json={"headless": False},
).raise_for_status()

info = requests.get(
    f"{BASE}/profiles/{profile_id}/selenium", headers=HEADERS
).json()["data"]

opts = webdriver.ChromeOptions()
opts.debugger_address = info["selenium"]["debugger_address"]
driver = webdriver.Chrome(options=opts)

driver.get("https://example.com/dashboard")
# ... work ...

driver.quit()
requests.post(f"{BASE}/profiles/{profile_id}/stop", headers=HEADERS)

The endpoint anchors are start and selenium.

Pin ChromeDriver to the core's current major version before the first run. This post won't print the number, because it changes with every upstream release. Look up the core's current major, then pin to it. I'd call this the most annoying step in the flow, since a number you can't hard-code is a number you have to keep checking. Skip it and Selenium Manager may fetch a driver for the machine's own Chrome, and the attach fails.

If you drive profiles with Playwright, a note on fidelity. Playwright's documentation says connectOverCDP attaches to an existing browser, and that "This connection is significantly lower fidelity than the Playwright protocol connection via browserType.connect()." Source: Playwright docs. Expect to hit gaps. And never call new_context() on that connection: it creates an incognito context outside the profile. Use contexts[0] and its first page.

Creating profiles in bulk works too: up to 100 per call from a naming pattern. There's no CSV importer, so don't plan around one.

Cost: $9.99/month or $99.99/year, unlimited profiles, with a 7-day free trial that requires a card. You aren't charged if you cancel before the trial ends.

When JustBrowser is the wrong choice

Said plainly, because it's the part that saves you a wasted trial.

  • You automate one account, or test your own app. A dedicated user-data-dir or Chrome for Testing is free and enough. Don't pay for a profile API you won't use.
  • Your CI runs on Linux. There's no Linux build. JustBrowser ships for Windows x64 and macOS (Apple Silicon) only, so it won't run on Linux runners.
  • You need a hosted endpoint. The API is local only. Nothing to call from a remote service.
  • You expect webhooks. There are none. To track a profile's state, poll GET /profiles/{id}/status.
  • Your teammates need API access on a free seat. Team seats are free, but they have no API access. The token requires a subscription or trial.
  • You forgot the headless default. Starting a profile is headless unless the request body sets headless to false. A script that "opens nothing" is usually this.

If none of those rule you out, and you're maintaining a pile of directories and locks, the API route is worth a trial. If one of them does, the free route above is the right one. For background on how sites tell browsers apart, ClickzProtect's explainer on browser versus TLS fingerprinting is a useful read. If your automation feeds a site you own, cookieless tracking on the JustAnalytics side explains what you'll and won't see in your own analytics. On the other side of the fence, ClickzProtect's guide to detecting headless browsers without JavaScript shows how sites try to spot automation like this.

A short decision rule

  • One account → dedicated --user-data-dir. Stop here.
  • Testing your own app → Chrome for Testing, pinned.
  • Several persistent identities, on Windows or macOS, scripted locally → the API route is worth a trial.
  • Runners that aren't Windows x64 or macOS (Apple Silicon), or a hosted endpoint → this post's second half doesn't apply, because JustBrowser runs only on those two platforms and its API is local. Build it yourself.

FAQ

Why does --remote-debugging-port stop working on my normal Chrome profile?

From Chrome 136, --remote-debugging-port and --remote-debugging-pipe are no longer respected when debugging the default Chrome data directory, per Chrome's developer blog as of November 2026. They must be paired with --user-data-dir pointing to a non-standard directory.

Can I just use a dedicated user-data-dir instead?

Yes, and for one account that's the right answer. Log in once in that directory and the session persists between runs. It's free and needs no extra tools.

Does JustBrowser run on Linux CI runners?

No. JustBrowser ships for Windows x64 and macOS (Apple Silicon) only, and there is no Linux build. Its API is also local-only, bound to 127.0.0.1, so it can't be called as a hosted service.

How do I attach Selenium to a JustBrowser profile?

Start the profile with POST /profiles/{id}/start, sending {"headless": false} if you need a visible window, then read GET /profiles/{id}/selenium for the debugger address. Pin ChromeDriver to the core's current major version first.


Try JustBrowser

A multi-account browser for teams, on a custom Chromium engine, always current with upstream — not extension-based. Real C++ engine patches at the canvas / WebGL / audio / font / screen layer, with 40+ identity parameters. REST API plus CDP for Playwright, Puppeteer, Selenium. One plan: $9.99/month or $99.99/year — unlimited profiles, free team seats, 7-day free trial.

Get started → · How it differs from Multilogin / GoLogin / AdsPower

Tags
  • selenium-chrome-profile
  • chrome-remote-debugging-port
  • user-data-dir
  • chromedriver-pinning
  • cdp-automation
  • buildinpublic
  • saasstudio
  • aiworkforce
  • buildwithclaude

Try the antidetect browser built for teams

Every profile gets its own fingerprint, cookies and proxy. A 7-day trial, then $9.99/month: one plan, everything included.

We'd like to use Google Analytics, a Google service, to understand how our website is used, and Google Ads and Microsoft Advertising to measure our ads and show them to people who have visited us. They set cookies in your browser and run only if you click Accept. You can change your choice at any time with Cookie settings. Cookie Policy

Sign-in cookies and the cookie that remembers this choice are always on; the website needs them to work.

Google Analytics, a Google service, helps us understand how our website is used, and Google Ads and Microsoft Advertising measure our ads and show them to people who have visited us. They set the cookies _ga, _ga_TVZHQ99TZW, _gcl_au, _uetsid and _uetvid, and, after a click on one of our ads, _gcl_aw or _uetmsclkid. They are now onoff in this browser. If your browser sends a Global Privacy Control or Do Not Track signal, they stay off. Cookie Policy