How to Change Selenium WebDriver's IP Address

Change WebDriver's IP address by routing Selenium through proxies: Chrome and Firefox setup, authentication, and IP rotation with code. Start rotating.

ST
Scraping.Pro Team
Data collection for business needs
Published: 6 May 2026

How to Change Selenium WebDriver's IP Address

When you scrape with a real browser, the target site sees the IP address of whatever machine is running WebDriver. Send too many requests from that one IP and you get rate-limited, served CAPTCHAs, or blocked outright. The fix is to change WebDriver's IP address by routing the browser through a proxy — and, at scale, to rotate across many proxies so no single address stands out. This guide shows the current Selenium 4 way to do it in Chrome and Firefox, how to handle proxy authentication (the part that trips everyone up), and how to rotate IPs, including with a rotating-proxy gateway.

Examples are in Python, but the WebDriver API is the same shape across languages, so they translate directly to Java, C#, or JavaScript.

How proxies change the browser's IP

A proxy is an intermediary server. Instead of connecting to the target directly, WebDriver sends its traffic to the proxy, which forwards it and returns the response. The target sees the proxy's IP, not yours. Swap in a different proxy and, from the site's perspective, a different visitor arrives. That is the whole mechanism behind rotating proxies for scraping.

Two things to get right up front:

  • Proxy type matters. Datacenter proxies are cheap and fast but easy to fingerprint and block in bulk. Residential and mobile proxies route through real ISP addresses and are much harder to flag, at higher cost. Choose based on how defensive the target is.
  • Selenium Manager handles drivers now. In Selenium 4, you no longer pass executable_path or download ChromeDriver by hand — Selenium Manager resolves the matching driver automatically. Old snippets using executable_path=... are deprecated.

Selenium proxy setup in Chrome

The simplest case is an unauthenticated proxy (one that lets you in by IP allowlist). Pass it with the --proxy-server argument:

python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument("--proxy-server=http://198.51.100.23:8080")

driver = webdriver.Chrome(options=options)   # Selenium Manager finds the driver
driver.get("https://httpbin.org/ip")
print(driver.page_source)   # should show the proxy's IP, not yours

--proxy-server accepts http://, https://, and socks5:// schemes. That is all it takes to change Chrome's outbound IP — as long as the proxy needs no username and password.

Selenium proxy setup in Firefox

Firefox takes its proxy through preferences on an Options object. The old FirefoxProfile approach is deprecated in Selenium 4; set preferences directly instead:

python
from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.set_preference("network.proxy.type", 1)          # 1 = manual config
options.set_preference("network.proxy.http", "198.51.100.23")
options.set_preference("network.proxy.http_port", 8080)
options.set_preference("network.proxy.ssl", "198.51.100.23")
options.set_preference("network.proxy.ssl_port", 8080)

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

Alternatively, both browsers accept a W3C-standard Proxy object, which is a clean, cross-browser way to express the same thing:

python
from selenium.webdriver.common.proxy import Proxy, ProxyType

proxy = Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy.http_proxy = "198.51.100.23:8080"
proxy.ssl_proxy = "198.51.100.23:8080"

options = webdriver.ChromeOptions()
proxy.add_to_capabilities(options.to_capabilities())
driver = webdriver.Chrome(options=options)

The hard part: authenticated proxies

Most commercial proxies require a username and password, and here is the catch that wastes hours: Chrome's --proxy-server flag has no way to pass credentials. When the proxy demands auth, Chrome pops a native dialog that Selenium cannot type into, and the request hangs. There are three practical ways around it.

Option 1 — IP allowlisting (simplest). Most proxy providers let you authorize your server's IP in their dashboard. Once allowlisted, the proxy accepts you without a username/password, and the plain --proxy-server setup above just works. If your scraper runs from a fixed IP, this is the cleanest path — no code gymnastics.

Option 2 — a small auth extension. Chrome can carry credentials through a tiny generated extension containing a background.js that answers the auth challenge via chrome.webRequest.onAuthRequired. You build the extension on the fly and load it with options.add_extension(...). It works headfully and is a well-worn pattern, but it is fiddly and does not work in every headless configuration.

Option 3 — selenium-wire (most convenient). The selenium-wire package extends Selenium and accepts authenticated proxies directly, credentials in the URL:

python
from seleniumwire import webdriver   # pip install selenium-wire

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

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

selenium-wire routes browser traffic through its own local proxy and handles the upstream authentication for you. It is the least painful option for authenticated proxies and also lets you inspect requests, which is handy for debugging.

Rotating IPs in Selenium

Changing to one proxy helps; rotating across many is what actually keeps you unblocked at scale. There are two models.

Model 1 — rotate a pool yourself

Keep a list of proxies and start a fresh browser session on a different one per batch. A proxy's configuration is fixed for the life of a WebDriver session, so to switch IPs you spin up a new driver:

python
import random
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

PROXIES = [
    "http://198.51.100.23:8080",
    "http://198.51.100.24:8080",
    "http://203.0.113.9:3128",
]

def make_driver(proxy):
    opts = Options()
    opts.add_argument(f"--proxy-server={proxy}")
    return webdriver.Chrome(options=opts)

for url in target_urls:
    driver = make_driver(random.choice(PROXIES))
    try:
        driver.get(url)
        # ... extract ...
    finally:
        driver.quit()   # new session next loop = new IP

Rotate on a schedule (every N requests), and back off or drop a proxy when it starts returning blocks or CAPTCHAs.

Model 2 — a rotating-proxy gateway (recommended at scale)

Managing a large pool by hand gets old fast. A rotating-proxy gateway solves this: the provider gives you a single endpoint (one host and port), and it rotates the exit IP behind the scenes on every request or on a sticky-session interval. Your Selenium config never changes — you point at the gateway once and the provider handles the rotation:

python
from seleniumwire import webdriver

# One fixed gateway endpoint; the provider rotates the exit IP for you
gateway = "http://user:pass@gateway.provider.com:7000"

seleniumwire_options = {
    "proxy": {"http": gateway, "https": gateway, "no_proxy": "localhost,127.0.0.1"}
}

driver = webdriver.Chrome(seleniumwire_options=seleniumwire_options)
driver.get("https://httpbin.org/ip")   # a different exit IP over time

This is by far the simplest way to get Selenium IP rotation across thousands of addresses: you configure one endpoint, and rotation, health-checking, and pool management are the provider's problem, not yours. Because gateways almost always require authentication, pair them with selenium-wire (or IP allowlisting) as shown above.

Verify the IP actually changed

Always confirm your proxy is in effect before trusting a run. Load an IP-echo endpoint and check the address:

python
driver.get("https://httpbin.org/ip")
print(driver.find_element("tag name", "body").text)

If it shows the proxy's IP (or a rotating set over time), you are set. If it shows your server's real IP, the proxy silently failed — a very common footgun with authenticated proxies where the auth dialog blocked the connection. Also send both HTTP and HTTPS through the proxy; routing only one leaks your real IP on the other.

FAQ

Can I change WebDriver's IP without restarting the browser? Not for a live session — a proxy is fixed for that session's lifetime, so to switch IPs you start a new WebDriver instance. The exception is a rotating gateway, where a single endpoint changes the exit IP for you without any code change.

Why does my authenticated proxy hang in headless Chrome? Chrome's --proxy-server can't pass a username and password, so it waits on a native auth dialog Selenium can't fill. Use IP allowlisting, an auth extension, or selenium-wire instead.

Datacenter or residential proxies for Selenium? Datacenter proxies are cheaper and faster but easier to block in bulk. Residential and mobile proxies use real ISP IPs and evade detection far better, at higher cost. Match the proxy type to how defensive the target is.

How often should I rotate IPs? It depends on the target's tolerance. Common approaches are rotating every N requests or per session, and dropping any proxy that starts returning blocks or CAPTCHAs. A gateway that rotates per request removes the guesswork.

Does a proxy alone stop me getting blocked? No. A proxy changes your IP, but fingerprint, headers, and request pacing also matter. Combine proxies with realistic browser settings and sensible delays; sites increasingly detect automation beyond the IP.

Wrapping up

Changing Selenium WebDriver's IP address comes down to a proxy: --proxy-server for Chrome, preferences or a Proxy object for Firefox, and selenium-wire or IP allowlisting when the proxy needs credentials. For real resilience, rotate — either by cycling a pool across fresh sessions or, more simply, by pointing at a rotating-proxy gateway that changes the exit IP for you. Verify with an IP-echo endpoint every run, and remember the IP is only one signal among several. When the proxy and anti-block upkeep outgrows your team, a managed web scraping service handles the rotation and fingerprinting so you can focus on the data.