Selenium integration

Proxies for Selenium

Chrome won’t take proxy credentials from Selenium options. Since Selenium 4.32, WebDriver BiDi answers the proxy login for you, with no extension and no selenium-wire. Below: tested Python and Node.js code for rotating and sticky residential IPs.

Residential proxies
Code tested on our gateway Selenium 4.32+ with Chrome Traffic never expires

What teams run Selenium through proxies for

Public data collection

Load public pages, such as prices, listings and search results, the way a visitor in that country sees them.

Localization and ad checks

Check that geo-targeted pages, translations and ads render correctly in each market, from a residential or mobile connection there.

Testing from outside your network

Point your existing Selenium test suite at other countries: geo-redirects, CDN rules, consent banners and checkout as an outside visitor sees them.

Connection details

Hostgate.proxyhat.com
SOCKS5 port1080
HTTP port8080
AuthenticationUsername and password from the Proxies page of your dashboard
Username for one browserUSERNAME-country-US-sid-a3f8c20d1e-ttl-30m

Everything after your username is a flag: -country-US picks the exit country, -type-mobile the mobile carrier pool, -sid-… keeps one IP and -ttl-30m sets for how long (up to 24 hours). Leave out -type-mobile for residential IPs.

Selenium proxy code

Replace USERNAME and PASSWORD with the proxy credentials from the Proxies page of your dashboard. Python: pip install -U selenium (4.32 or newer). Node.js: npm install selenium-webdriver.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.bidi.browsing_context import ReadinessState

options = webdriver.ChromeOptions()
options.enable_bidi = True  # proxy login runs over WebDriver BiDi
options.add_argument("--headless=new")
options.add_argument("--proxy-server=http://gate.proxyhat.com:8080")
driver = webdriver.Chrome(options=options)

# Chrome won't take credentials in the proxy URL: answer its 407 challenge instead.
driver.network.add_auth_handler("USERNAME-country-US", "PASSWORD")

# Navigate over BiDi: a classic driver.get() would block the auth reply in ChromeDriver.
driver.browsing_context.navigate(context=driver.current_window_handle,
    url="https://httpbin.org/ip", wait=ReadinessState.COMPLETE)
print(driver.find_element(By.TAG_NAME, "body").text)
driver.quit()

enable_bidi turns on WebDriver BiDi, and network.add_auth_handler answers the gateway’s 407 challenge. Load pages with browsing_context.navigate: in our test a classic driver.get() hung until it timed out, because ChromeDriver runs one command per session at a time and the login reply waited behind the page load.

Tested on November 28, 2026 against gate.proxyhat.com with Selenium 4.54.0 and Chrome 158 (the Python rotating sample also with Selenium 4.32.0). Every sample printed a US IP; the sticky sample printed the same IP twice.

Checked against: Selenium: WebDriver BiDi network, Selenium docs example (Python), Selenium Python changelog (4.32.0) · checked November 28, 2026

Rotating, sticky or no rotation

The session type is part of the username. Your code stays the same; only the login string changes.

Rotating

No session ID: each new connection can exit from a different IP. Good for many independent page loads.

USERNAME-country-US

Sticky

Add -sid- with 10 random hex characters and a -ttl-: the IP holds for that long (10m, 30m, 1h, up to 24h). Use it for multi-page flows that should stay on one address.

USERNAME-country-US-sid-a3f8c20d1e-ttl-30m

No rotation

Add -sid- with -norotate-true and no -ttl-: the IP doesn’t rotate on a timer and stays until you switch to a new sid.

USERNAME-country-US-sid-a3f8c20d1e-norotate-true

One sid holds one exit IP and handles about 4–5 connections at a time, so give every worker or browser its own sid. Sticky sessions last up to 24 hours. Add -type-mobile for 4G/5G carrier IPs; leave it out for residential.

Proxy errors and what they mean

407 Proxy Authentication RequiredThe gateway didn’t accept the login: the username or password is wrong, or the username format is (a typo in a flag such as -country-US). Copy both from the Proxies page of your dashboard and make sure the auth step runs before the first page load.
402 Payment RequiredThe traffic balance is used up, or the sub-user has reached its traffic limit. Top up or raise the limit in the dashboard; traffic you buy never expires.
ERR_TUNNEL_CONNECTION_FAILEDChrome’s name for a proxy that refused the connection, and it can hide a 402 or another gateway status. Send the same username and password through curl -x http://gate.proxyhat.com:8080 to see the real code.
ERR_PROXY_CONNECTION_FAILEDChrome couldn’t reach the gateway at all. Check the host and port (gate.proxyhat.com, 8080 for HTTP) and that your network allows outgoing connections to it.

All gateway errors and username flags are in the documentation: ProxyHat docs →

Price

Mobile and residential traffic share one price and one balance: from $4.00/GB for a 1 GB pack down to $1.80/GB for 1,000 GB. Traffic never expires, and all your browsers draw from the same balance. See pricing →

Selenium proxy setup: FAQ

Which Selenium version do I need?

Selenium 4.32 or newer for Python: network.add_auth_handler arrived in 4.32.0, and 4.31 lacks the BiDi modules the samples import. We tested 4.54.0 with Chrome 158. Keep Chrome and ChromeDriver on the same major version; Selenium Manager handles that for you.

Why doesn’t options.proxy or --proxy-server take my password?

Chrome reads only the address from them and ignores a user:pass part. The password has to be sent when the gateway asks for it (HTTP 407), which is what the BiDi auth handler does.

Why browsing_context.navigate instead of driver.get()?

With the auth handler on, driver.get() hung in our test until it timed out: ChromeDriver handles one command per session at a time, and the BiDi reply with the credentials waited behind the page load. Navigate over BiDi; find_element and the other classic commands work as usual afterwards.

Do I still need selenium-wire or a proxy extension?

No. selenium-wire is archived and no longer maintained, and a Chrome extension adds one more moving part. The BiDi auth handler is built into Selenium.

Can I use SOCKS5?

Not with a password in Chrome: Chromium supports SOCKS5 only without authentication. Use HTTP on port 8080; it carries HTTPS sites too.

How do I run several browsers with different IPs?

Start one driver per worker and give each its own sid, as new_driver() does in the sticky sample. A sid handles about 4–5 parallel connections and keeps its IP for the -ttl- you set, up to 24 hours.

How do I pick a country or use mobile IPs?

Add -country- with a two-letter code (residential IPs in 195+ countries) and -type-mobile for 4G/5G carrier IPs (150+ countries). Mobile and residential cost the same and draw from one balance.

Do I need a browser at all?

Not for pages that render without JavaScript: an HTTP client such as requests takes the same gateway, username and password and uses far less traffic. Our Python proxy guide, linked below, covers requests and the ProxyHat SDK.

Run Selenium through residential IPs

Create an account, buy a small pack and run the samples above before you scale out.

Pay as you go · Traffic never expires · Crypto checkout