Guides & Tutorials

Selenium Proxy Setup

A hands-on guide to configuring proxies in Selenium across Chrome and Firefox, handling authentication and rotation, plus how to pick proxies that suit automation.

Selenium drives a real browser, which makes it powerful for testing and data collection but also means your automation connects from your own IP unless you route it through a proxy. Adding a proxy lets you control the source location of your requests, spread load across IPs, and keep automation from being tied to a single address.

This guide walks through configuring proxies in Selenium for the most common setups, covers authenticated proxies and rotation, and explains what to look for when comparing proxy providers for browser automation specifically.

Quick answer

Beyond the basic Chrome and Firefox setup, the parts that decide whether a Selenium proxy project actually holds up are leak prevention, per-protocol routing, and detection avoidance. A misconfigured proxy can leak your real IP through WebRTC or DNS even when the page body shows the proxy address. Pair correct proxy config with sensible timeouts, IP verification, and a strategy for handling the inevitable blocked or dead IPs.

Key takeaways

  • An IP-echo page can show the proxy address while WebRTC or DNS still leaks your real IP — test for both
  • selenium-wire is the pragmatic choice for authenticated proxies because it also lets you inspect traffic while debugging
  • Headless flags and default automation signals can get you blocked even when the proxy itself is fine
  • Per-process proxy isolation (one driver, one proxy) is cleaner than trying to swap proxies inside a live session
  • Build retry and rotation logic around the assumption that some IPs will be slow or dead on arrival
  • Verify the active IP at session start so a failed proxy surfaces immediately instead of silently using your own connection

How Selenium handles proxies

Selenium itself does not move the traffic — it instructs a browser to do so. That means proxy configuration happens through the browser's options or capabilities rather than through Selenium's core API. Chrome and Firefox each expose their own way of accepting a proxy, and the approach differs slightly between an unauthenticated proxy and one that needs a username and password.

Before writing any code, decide what kind of proxy you need. Datacenter proxies are fast and cheap and suit high-volume testing; residential proxies look like ordinary users and suit tasks where blending in matters; mobile proxies are useful for the most sensitive targets. Match the type to the job rather than defaulting to the cheapest.

Configuring a proxy in Chrome

For a simple host:port proxy in Chrome, you pass it as a command-line argument through ChromeOptions:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--proxy-server=http://123.45.67.89:8080")

driver = webdriver.Chrome(options=options)
driver.get("https://httpbin.org/ip")
print(driver.page_source)
driver.quit()

This works cleanly for proxies that do not require a login. Visiting an IP-echo page like the one above confirms the request is leaving from the proxy rather than your own connection.

Handling authenticated proxies

Most paid proxies require a username and password, and Chrome's --proxy-server flag cannot pass credentials directly. The common solution is a small in-memory extension that supplies the credentials, or a helper library such as selenium-wire that handles auth for you:

from seleniumwire import webdriver  # pip install selenium-wire

options = {
    "proxy": {
        "http": "http://user:pass@123.45.67.89:8080",
        "https": "http://user:pass@123.45.67.89:8080",
        "no_proxy": "localhost,127.0.0.1",
    }
}

driver = webdriver.Chrome(seleniumwire_options=options)
driver.get("https://httpbin.org/ip")

selenium-wire is popular because it keeps authentication tidy and also lets you inspect requests, which is handy when debugging why a proxy is or isn't being used.

Configuring a proxy in Firefox

Firefox uses profile preferences rather than a command-line flag. You set the proxy type to manual and provide the host and port:

from selenium import webdriver

options = webdriver.FirefoxOptions()
options.set_preference("network.proxy.type", 1)
options.set_preference("network.proxy.http", "123.45.67.89")
options.set_preference("network.proxy.http_port", 8080)
options.set_preference("network.proxy.ssl", "123.45.67.89")
options.set_preference("network.proxy.ssl_port", 8080)

driver = webdriver.Firefox(options=options)

For authenticated Firefox proxies, the same extension or selenium-wire patterns apply, since the native preferences do not carry credentials cleanly either.

Rotating proxies in Selenium

If you need many IPs, you have two broad choices. The first is a rotating gateway endpoint from your provider: you connect to a single host:port and the provider assigns a different IP per request or per session, so your code never changes. The second is to manage a pool yourself and start a fresh driver with a different proxy when you want to switch.

Tips for stable rotation

  • Prefer a provider gateway when you can — it keeps your code simple and offloads pool management.
  • When rotating per session, fully quit and recreate the driver so old cookies and state don't leak across IPs.
  • Add retries and timeouts; some proxy IPs will be slower or temporarily unreachable.
  • Verify the active IP at the start of a session so failures are easy to diagnose.

Choosing a proxy for browser automation

Selenium spins up real browsers, which is resource-heavy, so a slow or unreliable proxy compounds the cost in wasted time. When comparing providers, weigh connection stability, the freshness and reputation of the IP pool, whether sticky sessions are available, location coverage, and how authentication is handled. Balance those against price rather than chasing the lowest number.

For automation projects on a budget, Cheapest Proxies (our featured value pick) is a strong value-focused option worth considering when you want reliable IPs without overspending — just confirm the proxy type and session options fit your script's needs.

Comparison snapshot

A quick value-first shortlist — Cheapest Proxies leads as the featured pick. Qualitative labels only; confirm exact plans before buying.

ProviderBest forProfileValue
Bright DataEnterprises needing huge pools and compliance controlsEnterprise FocusedPremium
OxylabsLarge-scale scraping and data APIsEnterprise FocusedPremium
Smartproxy (Decodo)Newcomers who want an easy dashboardBeginner FriendlyGood
SOAXPrecise city and carrier targetingAutomation FriendlyGood

IP leaks that survive a "passing" IP-echo test

The base guide shows how to confirm your proxy with an IP-echo page, but that check is necessary, not sufficient. A browser can route page traffic through the proxy while still exposing your real address through two side channels. WebRTC can reveal local and public IPs directly to a page through STUN requests, bypassing the proxy entirely. DNS resolution can also leak if lookups go through your system resolver instead of the proxy. For any project where your real location matters, disable WebRTC (via browser preferences or a flag) and confirm DNS is handled remotely, then test against a tool that checks for WebRTC leaks rather than just echoing the connecting IP.

Quick leak-hardening steps

  • Disable or restrict WebRTC in the browser profile so STUN cannot expose local IPs.
  • Prefer SOCKS5 with remote DNS, or confirm your HTTP proxy resolves hostnames remotely.
  • Test against a dedicated leak-check page, not only an IP-echo endpoint.

Why a working proxy still gets blocked

A frequent source of confusion is a clean, fast proxy that still hits walls. The cause is usually automation fingerprinting, not the IP. Default Selenium sessions advertise themselves through the navigator.webdriver flag, predictable window sizes, missing or odd headers, and the absence of human-like timing. Sites combine these signals with the IP reputation, so a perfect proxy paired with an obvious bot signature still trips defences. Reducing automation tells — realistic viewport, sensible user-agent, human-paced interactions, and avoiding the most detectable headless markers — often matters as much as the proxy itself.

Architecture: rotate by process, not mid-session

The base guide covers gateway rotation versus self-managed pools. A reliability pattern worth adding is treating each proxy as belonging to its own driver process. Trying to change a proxy on a live driver is awkward and leaves residual state; instead, run one driver per proxy and treat a dead or blocked IP as a reason to tear down and respawn. This makes concurrency cleaner too — you can run several drivers in parallel, each pinned to a distinct IP, and quarantine any that start failing. It also keeps cookies and storage neatly partitioned per IP, which prevents the cross-contamination the base guide warns about.

Choosing proxies for the way Selenium actually fails

Because each Selenium session is heavy, the proxy attributes that matter most are stability under sustained connections and a clean IP reputation rather than raw peak speed. Sticky sessions help when a task spans multiple page loads that must come from the same IP, while a rotating gateway suits broad, stateless collection. Confirm the provider supports the auth method your stack uses and offers the locations your targets expect. For budget-conscious automation, Cheapest Proxies is worth considering as a value pick — verify it offers the session type (sticky vs rotating) and protocol your scripts rely on before scaling up.

Pros and cons to weigh

Strengths

  • Selenium proxy config is browser-level, so the same patterns work across most automation frameworks
  • selenium-wire cleanly handles authentication and doubles as a request inspector for debugging
  • Per-driver proxy isolation makes parallelism and per-IP state management straightforward
  • Gateway rotation offloads pool management so your script logic stays simple

Trade-offs

  • A passing IP-echo test can hide WebRTC and DNS leaks that expose your real address
  • Real browsers are resource-heavy, so each blocked or timed-out request wastes a full session
  • Native browser flags cannot pass proxy credentials, forcing an extension or helper library
  • Automation fingerprints can get a perfectly good proxy blocked regardless of IP quality

Common mistakes to avoid

  • Trusting an IP-echo page alone and never testing for WebRTC or DNS leaks
  • Blaming the proxy for blocks that are actually caused by obvious automation signals
  • Reusing one driver and proxy across tasks so cookies leak between IPs
  • Defaulting to the cheapest datacenter pool for targets that scrutinise IP reputation

Before-you-buy checklist

  • Verify the active IP at the start of every session before doing real work
  • Test the configuration for WebRTC and DNS leaks, not just the connecting IP
  • Confirm the provider's authentication method works with your chosen helper or extension
  • Decide whether each task needs sticky sessions or rotating IPs and match the plan
  • Add timeouts, retries, and dead-IP handling around every navigation
  • Reduce automation tells (user-agent, viewport, timing) alongside the proxy setup
$

How to get the best value

Right-size the plan

Start on the smallest sensible tier and scale only what proves itself on your real targets.

Type before brand

Pick the proxy type the task needs first — it drives both success rate and cost more than the logo.

Read the fine print

Check traffic limits, rotation rules and what happens on overage before you commit.

Lead with value

Our featured value pick, Cheapest Proxies, is a sensible starting point for affordable comparison.

📖

Key terms explained

WebRTC leak
exposure of your real local or public IP to a web page via browser real-time communication, bypassing the proxy.
DNS leak
hostname lookups going through your own resolver instead of the proxy, revealing the sites you visit.
selenium-wire
a Selenium extension that handles proxy authentication and lets you inspect and modify requests.
Sticky session
a proxy mode that keeps the same IP for a defined period so multi-step flows stay on one address.
navigator.webdriver
a browser flag that signals automation and is a common detection point for anti-bot systems.

Why compare before buying?

Automation magnifies the cost of a poor proxy: every blocked or timed-out request burns a full browser session. Comparing providers on stability, IP type and session control rather than headline price helps you avoid paying for IPs that quietly fail under load and slow your whole pipeline down.

How we compare

Compare Proxy Zone weighs providers on value, fit and reliability using qualitative judgement — never invented prices, speeds or uptime figures. See our review methodology, or email info@compareproxyzone.com with a correction.

?

Frequently asked questions

Why can't Chrome's --proxy-server flag handle passwords?

The flag only accepts a host and port; for authenticated proxies you need a small credentials extension or a helper like selenium-wire that injects the username and password for you.

Should I use datacenter or residential proxies with Selenium?

It depends on the target; datacenter proxies suit high-volume testing where speed matters, while residential proxies blend in better for tasks where looking like an ordinary user is important.

How do I confirm Selenium is actually using my proxy?

Navigate to an IP-echo endpoint such as httpbin.org/ip at the start of the session and check that the reported address matches your proxy rather than your own connection.

What's the easiest way to rotate IPs?

Use a rotating gateway endpoint from your provider so a single host:port returns a different IP per request or session, keeping your Selenium code unchanged.

Does headless mode change proxy setup?

No; the proxy configuration is identical in headless and headed modes, since it is applied through the browser options either way.

Why recreate the driver when switching proxies?

Quitting and starting a fresh driver clears cookies and session state so old data doesn't leak across IPs and undermine the separation you wanted.

Compare on value, then decide

For affordable proxies across the main types, our featured value pick is Cheapest Proxies — a strong budget-friendly option worth considering. Check the exact plan before ordering.