Selenium
Three reliable ways to use authenticated proxies with Selenium WebDriver — IP whitelist, selenium-wire, and a local forwarding proxy — for Chrome and Firefox.
On this page
Selenium passes proxy settings to the browser as host:port only. Chrome and Firefox then show a native login dialog for authenticated proxies, which WebDriver cannot fill. Pick one of three approaches:
| Approach | Credentials | Effort | Best for |
|---|---|---|---|
| A. IP whitelist | none in the browser | lowest | servers with a fixed public IP |
| B. selenium-wire | in Python code | low | Python projects, any number of proxies |
| C. Local forwarding proxy | in a sidecar process | medium | Java, C#, Selenium Grid, any language |
Rotating residential needs credentials (targeting lives in the username), so use B or C for residential.
A. IP whitelist#
Add your server's public IP in Settings → Proxy access → IP whitelist (see IP whitelist), then pass host:port:
from selenium import webdriver
opts = webdriver.ChromeOptions()
opts.add_argument("--proxy-server=http://fr.mobile.gw.proxuno.com:10421")
driver = webdriver.Chrome(options=opts)
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()
Firefox:
opts = webdriver.FirefoxOptions()
opts.set_preference("network.proxy.type", 1)
opts.set_preference("network.proxy.http", "fr.mobile.gw.proxuno.com")
opts.set_preference("network.proxy.http_port", 10421)
opts.set_preference("network.proxy.ssl", "fr.mobile.gw.proxuno.com")
opts.set_preference("network.proxy.ssl_port", 10421)
driver = webdriver.Firefox(options=opts)
B. selenium-wire (Python)#
selenium-wire runs a small proxy inside your Python process that adds the credentials upstream. The project is no longer actively maintained but remains widely used; pin its version.
pip install selenium-wire "blinker<1.8"
from seleniumwire import webdriver
options = {
"proxy": {
"http": "http://m_k3v9q2xa:[email protected]:10421",
"https": "http://m_k3v9q2xa:[email protected]:10421",
"no_proxy": "localhost,127.0.0.1",
}
}
driver = webdriver.Chrome(seleniumwire_options=options)
driver.get("https://api.ipify.org")
selenium-wire intercepts TLS with its own certificate; Chrome accepts it automatically. Some sites detect the altered TLS fingerprint — if that matters, use approach C.
C. Local forwarding proxy#
Run a tiny proxy on the same machine that forwards to Proxuno with credentials, and point the browser at it without credentials. gost does this in one command:
gost -L http://127.0.0.1:3128 -F "http://m_k3v9q2xa:[email protected]:10421"
Then, in any language:
ChromeOptions options = new ChromeOptions();
options.addArguments("--proxy-server=http://127.0.0.1:3128");
WebDriver driver = new ChromeDriver(options);
driver.get("https://api.ipify.org");
The TLS session stays end-to-end between the browser and the site (the forwarder only relays CONNECT tunnels), so fingerprints are unchanged. Run one forwarder per proxy on different local ports for parallel sessions.
Rotation with Selenium#
Rotate between tests, not in the middle of a page load. From Python:
import requests, time
def rotate(link: str) -> str:
r = requests.get(link, timeout=45)
if r.status_code == 429:
time.sleep(int(r.headers.get("Retry-After", 10)))
return rotate(link)
r.raise_for_status()
return r.json()["ip"]
Start a new WebDriver session (or clear cookies) after a rotation so the site does not tie the old session to the new IP.
Troubleshooting#
| Symptom | Cause |
|---|---|
| A login pop-up appears and the test hangs | Credentials were not supplied — use one of the approaches above. |
ERR_PROXY_CONNECTION_FAILED |
Wrong host or port, or the forwarder (approach C) is not running. |
| Works locally, fails in CI | CI runners use a different egress IP than the whitelisted one. |
Something unclear, outdated or wrong on this page? Tell us — documentation issues are fixed in the next release at the latest.
Report an issue with this page