← Blog

BLOG

Playwright connect_over_cdp Firefox Supported Docs: A Practical Guide

Playwright connect_over_cdp Firefox supported docs: connect to hosted Firefox via CDP, keep sessions alive, and run reliable browser automation.

August 28, 20268 min readRemote Browser

# Playwright connect_over_cdp Firefox Supported Docs: A Practical Guide

If you've searched for playwright connect_over_cdp firefox supported docs, you're likely trying to connect Playwright to a remote Firefox instance over the Chrome DevTools Protocol (CDP). The short answer: yes, Playwright supports connect_over_cdp for Firefox, but the implementation has specific constraints, and production use requires more than a local browser process. This guide explains exactly how it works, where it breaks down, and how to run Firefox-based automation reliably in the cloud.

What connect_over_cdp Actually Does

Playwright's connect_over_cdp method attaches to an existing browser instance via CDP rather than launching a new one. This is useful when you need to control a browser that's already running—perhaps in a remote environment, a container, or a session managed by another tool.

For Chromium-based browsers, this works seamlessly. For Firefox, the story is more nuanced. Firefox supports CDP through its remote debugging protocol, but it's not a full implementation of the Chrome DevTools Protocol. Playwright's documentation notes that Firefox's CDP support is partial, and some operations behave differently compared to Chromium.

Here's a minimal TypeScript example that connects to a remote Firefox instance:

import { chromium } from 'playwright';

// Note: Playwright uses the 'chromium' export for CDP connections,
// even when connecting to Firefox over CDP.
async function connectToFirefox() {
  const browser = await chromium.connectOverCDP(
    'http://localhost:9222'
  );

  const context = browser.contexts()[0];
  const page = context.pages()[0];

  await page.goto('https://example.com');
  console.log(await page.title());

  await browser.close();
}

connectToFirefox().catch(console.error);

The key takeaway: you use the chromium API surface because CDP is a Chromium-originated protocol. Firefox implements a subset of it, so you're effectively speaking CDP to a Firefox process.

Firefox CDP Support: What's Documented and What's Not

The Playwright docs are clear about Firefox CDP limitations. According to the official Playwright documentation, Firefox's CDP support is experimental and incomplete. Some features that work in Chromium over CDP—like certain network interception methods, performance metrics, and specific DOM APIs—may not behave identically in Firefox.

What works reliably in Firefox over CDP:

  • Basic navigation and page loading
  • DOM querying and manipulation
  • Clicking, typing, and form submission
  • Screenshot and PDF generation
  • Basic network request observation

What's less reliable or unsupported:

  • Full network interception with request/response modification
  • Some emulation features (device metrics, geolocation)
  • Performance timeline APIs
  • Certain CDP domains that Firefox hasn't implemented

This matters for production automation. If your workflow depends on network mocking or advanced emulation, Firefox over CDP may not be the right choice. If you need basic browser automation with Firefox's rendering engine, it can work.

Why Local Firefox CDP Fails in Production

Connecting to a local Firefox instance via CDP works fine for development. But production browser automation has different requirements:

Session persistence. A local Firefox process dies when your machine restarts, when the process crashes, or when your CI runner is recycled. For AI agents that need to maintain state across multiple steps or retries, this is a non-starter.

Concurrency. Running multiple Firefox instances locally means managing multiple processes, ports, and profiles. This gets messy quickly, especially if you're orchestrating dozens of parallel tasks.

Infrastructure overhead. You need to install Firefox, configure the remote debugging port, manage the process lifecycle, and handle crashes. That's a lot of moving parts for what should be a simple API call.

Network and IP considerations. If your automation needs to appear as a real user from a specific geographic location or avoid bot detection, a local browser on a datacenter IP is a liability.

The Production Alternative: Hosted Firefox via CDP

Remote Browser provides hosted Chromium sessions with CDP access, and the same infrastructure supports Firefox-based automation workflows. Instead of managing a local Firefox process, you connect to a remote browser session over CDP—the same way you'd connect to a local one, but without the infrastructure burden.

Here's how the architecture changes:

AspectLocal Firefox + CDPHosted Browser + CDP
Session persistenceDies with the processPersistent across connections
ConcurrencyManual process managementManaged by the platform
InfrastructureYou install and maintain FirefoxZero setup, API-only
IP qualityDatacenter IPConfigurable proxy settings
Live debuggingLocal onlyWeb-based live viewer
ScalingLimited by local resourcesHorizontal scaling

The connection code is nearly identical. You're still using connect_over_cdp, but the endpoint points to a hosted session rather than localhost.

Keeping Browser Sessions Alive Across Cloud Workers

One of the most common questions we hear: "How do I keep browser sessions alive across multiple cloud workers?" This is a real problem when you're using serverless functions or ephemeral compute.

The issue is that a browser session is stateful. If worker A opens a page, logs in, and then worker B tries to continue that session, worker B needs access to the same browser context. With local browsers, this is impossible—each worker has its own isolated environment.

With hosted browsers, the session lives in the cloud, not on your worker. Any worker can connect to the same session via CDP, pick up where the previous worker left off, and continue the task. This is how you build multi-step AI agents that survive infrastructure failures and scale horizontally.

The pattern looks like this:

  1. Worker A connects to a hosted browser session via CDP
  2. Worker A performs steps 1-3 of a task, then exits
  3. Worker B connects to the same session via CDP
  4. Worker B sees the state left by Worker A and continues

This is the foundation for reliable AI web agents. The browser is the persistent state layer; your workers are stateless compute that attach and detach as needed.

How to Give Your AI Agent Browser Access in Production

If you're building an AI agent that needs to browse the web, you have a few options:

Option 1: Local browser automation. Install Playwright or Puppeteer on your agent's machine, launch a browser, and control it directly. This works for prototypes but fails in production due to the infrastructure and persistence issues discussed above.

Option 2: Browser-use style frameworks. Tools like browser-use provide a higher-level interface for AI agents. They handle the browser control logic, but you still need a browser runtime underneath.

Option 3: Hosted browser runtime. Connect your agent to a hosted browser via CDP. Your agent gets a real browser session with persistent state, configurable proxy settings, and live debugging—without managing any infrastructure.

The third option is what Remote Browser provides. Your AI agent connects to a hosted session, performs its tasks, and disconnects. The session persists, so the agent can reconnect later or a different agent can continue the work.

Practical Considerations for Firefox over CDP

If you're committed to Firefox over CDP, here are the production criteria to evaluate:

Session isolation. Can you isolate sessions so different tasks don't interfere with each other? With hosted browsers, each session is isolated by default.

Proxy and IP configuration. Can you route traffic through specific proxies or IPs? This is critical for tasks that need to appear from specific locations or avoid rate limiting.

Live debugging. Can you watch what the browser is doing in real time? A live viewer is invaluable for debugging AI agent behavior.

Usage controls. Can you set limits on session duration, concurrent sessions, or spending? This prevents runaway costs from misbehaving agents.

API stability. Does the CDP endpoint remain stable across reconnects? Your agent should be able to disconnect and reconnect without losing state.

When to Use Firefox vs. Chromium

Firefox over CDP is a niche use case. Most automation workloads are better served by Chromium, which has full CDP support and broader compatibility with automation libraries. But there are legitimate reasons to use Firefox:

  • Testing Firefox-specific behavior. If your product needs to work in Firefox, you need to test in Firefox.
  • Rendering differences. Firefox's rendering engine differs from Chromium, and some sites behave differently.
  • Privacy preferences. Some users prefer Firefox for privacy reasons, and your automation may need to match that.

For everything else, Chromium is the safer choice. It has complete CDP support, better Playwright integration, and a larger ecosystem of tools and libraries.

Getting Started with Hosted Browser Sessions

To connect to a hosted browser session via CDP, you'll need an API endpoint and authentication. The Remote Browser API provides this out of the box. You create a session, get a CDP endpoint, and connect with Playwright or any other CDP-compatible client.

The workflow is straightforward:

  1. Create a browser session via the API
  2. Retrieve the CDP endpoint URL
  3. Connect using connect_over_cdp or your preferred client
  4. Run your automation
  5. Disconnect when done (the session persists)

For detailed setup instructions, see the Remote Browser documentation. For pricing details, check the pricing page.

The Bottom Line

Playwright's connect_over_cdp for Firefox is supported, but it's not a drop-in replacement for Chromium. The protocol support is partial, and production use requires infrastructure that local browsers can't provide.

For reliable browser automation—whether you're running tests, powering AI agents, or scraping data—a hosted browser runtime solves the persistence, concurrency, and infrastructure problems that plague local setups. The connection code is the same; the difference is where the browser runs.

If you're building AI agents that need browser access, start with a hosted runtime. Your agents will be more reliable, your infrastructure simpler, and your debugging easier. For more on how hosted browsers fit into AI agent workflows, read about remote browsers for AI agents or explore remote browser online for a practical overview.

For the authoritative reference on CDP, see the Chrome DevTools Protocol documentation. For Playwright-specific details, the Playwright CDP documentation is the canonical source.