Change language
English Русский Deutsch Español Français Italiano Українська Tiếng Việt Türkçe Bahasa Indonesia हिन्दी 日本語 中文
Menu
Pricing
Proxies
Solutions
Resources

How to use a proxy with Selenium

Run Chrome or Firefox under Selenium through one static ISP address. Every sample on this page was run against a local proxy before it was published, and what did not work is said plainly.

In short: In Chrome, pass --proxy-server=http://HOST:PORT as an argument; in Firefox, set a manual Proxy on the options. Firefox can answer the proxy’s password prompt through Selenium’s WebDriver BiDi handler, add_authentication_handler. Chrome could not in our test: it ignores credentials in --proxy-server, and both BiDi handlers timed out. For Chrome, put the IP your tests run from on the proxy’s whitelist, and the proxy needs no credentials, over HTTP or SOCKS5.

Selenium does not route traffic itself: it starts a browser and hands it the proxy as part of the browser’s options. That is why the answer differs between Chrome and Firefox, and why proxy authentication is where most setups fail.

Python Selenium proxy for Chrome and Firefox

Chrome reads the proxy from a command-line switch, Firefox from a proxy object on its options. Both accept a whitelisted proxy with no further setup; Firefox can also answer the proxy’s password prompt through WebDriver BiDi, which Chrome did not do in our test.

Set a proxy in Selenium

  1. Find the public IP your tests run from

    The address of the machine or CI runner as the internet sees it, not its local one. What Is My IP shows it.

  2. Put that IP on the proxy's whitelist

    One API call, PUT /orders/ORDER_ID/whitelist, or the set_proxy_whitelist tool of the MCP server; the dashboard has no control for it yet. The whitelist takes IPv4 addresses and replaces the list each time. While a whitelist is set, the proxy admits only the listed addresses and the username and password stop working for that order; sending an empty list turns the whitelist off and password login works again.

  3. Copy the host and port from the order

    From My Proxies or the API. With the whitelist in place, the username and password are not needed.

  4. Set the proxy on the browser options

    Chrome: --proxy-server=http://HOST:PORT, or socks5://HOST:PORT after switching the proxy to SOCKS5. Firefox: a manual Proxy with httpProxy and sslProxy.

  5. Open a page and check the exit address

    Load What Is My IP in the driven browser once and confirm it shows the address you bought, then run the suite.

# The proxy has your machine's IP on its whitelist, so no credentials
# are sent: Chrome ignores them in --proxy-server anyway.
from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--headless=new")  # remove to watch the browser
options.add_argument("--proxy-server=http://HOST:PORT")

driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com/")
    print(driver.title)
finally:
    driver.quit()
# Selenium 4.51+ with WebDriver BiDi; pip install selenium
from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType

options = webdriver.FirefoxOptions()
options.enable_bidi = True
options.add_argument("-headless")  # remove to watch the browser
options.proxy = Proxy({
    "proxyType": ProxyType.MANUAL,
    "httpProxy": "HOST:PORT",
    "sslProxy": "HOST:PORT",
})

driver = webdriver.Firefox(options=options)
try:
    # Answers the proxy's 407 with your username and password
    driver.network.add_authentication_handler(
        lambda request: request.provide_credentials("USERNAME", "PASSWORD")
    )
    driver.get("https://example.com/")
    print(driver.title)
finally:
    driver.quit()
# The proxy has your machine's IP on its whitelist, so no credentials
# are sent. For a password instead, see selenium-firefox-auth.
from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType

options = webdriver.FirefoxOptions()
options.add_argument("-headless")  # remove to watch the browser
options.proxy = Proxy({
    "proxyType": ProxyType.MANUAL,
    "httpProxy": "HOST:PORT",
    "sslProxy": "HOST:PORT",
})

driver = webdriver.Firefox(options=options)
try:
    driver.get("https://example.com/")
    print(driver.title)
finally:
    driver.quit()
# Switch the proxy to SOCKS5 first, then use the port the order shows.
# The whitelist applies to SOCKS5 as well, so no credentials here either.
from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--headless=new")  # remove to watch the browser
options.add_argument("--proxy-server=socks5://HOST:PORT")

driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com/")
    print(driver.title)
finally:
    driver.quit()
# Put the public IPv4 address your code runs from on the proxy's
# whitelist. Replaces the list; an empty list turns whitelisting off
# and the proxy falls back to username and password.
curl -X PUT "https://api.proxyjam.com/public/v1/orders/ORDER_ID/whitelist" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"whitelisted_ips": ["YOUR_IP"]}'

Tested code for Selenium 4 in Python

The Firefox password sample sends a username and password, so it needs an order with no whitelist set. The other browser samples assume your machine's IP is on the proxy's whitelist; the SOCKS5 one also needs the proxy switched to SOCKS5 first, which gives a new port. Replace the capitals with your order's values, and ORDER_ID, YOUR_API_KEY and YOUR_IP in the whitelist call.

Full API docs

Proxy options in Selenium, browser by browser

Tested on 2026-10-22 with Selenium 4.51, Chrome and Firefox in headless mode, against a local proxy that required a password on one port and accepted a whitelisted client on another.
HTTP proxySOCKS5 proxyUsername and password
Chrome--proxy-server=http://HOST:PORT--proxy-server=socks5://HOST:PORTIgnored in --proxy-server; use the whitelist
FirefoxProxy with httpProxy and sslProxyProxy with socksProxy and socksVersion 5Worked through add_authentication_handler (BiDi), over HTTP
Chrome, BiDi handlersadd_auth_handler and add_authentication_handler both timed outNot testedUse the whitelist until a later Selenium or Chrome changes this

What goes wrong with Selenium and proxies

Credentials inside --proxy-server

Chrome drops the username and password from that argument without an error, connects without them and gets a 407 from the proxy. The page then fails to load, which looks like a network problem rather than an authentication one.

The driver download goes through the proxy

When Firefox options carry a proxy, Selenium Manager fetches the driver through that same proxy. With a password-only proxy that download fails before the browser starts; with the whitelist it succeeds.

The whitelist holds the wrong address

A CI runner often leaves from a different public IP than your laptop, and some change between runs. Whitelist the address the tests run from, and update it when that changes, since each call replaces the list.

SOCKS5 in the browser before the switch

An address set to HTTP does not answer SOCKS5. Switch the proxy on your order first and use the port it then shows; changing the scheme in the argument alone gives a browser that cannot connect.

What a browser test gets from the address

No password in the browser
The whitelist admits your runner's IPv4 address, so no secret sits in options or logs
Both browser schemes
http:// for ordinary pages, socks5:// once the order is switched
Same origin each run
Yesterday's run and today's leave from one IP, held for the whole billing period
Parallel drivers
Several drivers may share the address, or each driver may get its own

Other guides, and the product

Questions about proxies in Selenium

How do I use a proxy with authentication in Selenium?

In Firefox, enable WebDriver BiDi and register a handler with driver.network.add_authentication_handler that provides the username and password; that worked with Selenium 4.51. In Chrome nothing that sends credentials worked in our test: it ignores them in the proxy switch, and both BiDi handlers timed out. For Chrome, whitelist the public IP your tests run from, and the browser connects with no credentials at all.

How do I set up a proxy in Python Selenium for Chrome?

Create ChromeOptions, add the argument --proxy-server=http://HOST:PORT, and pass the options to webdriver.Chrome. For SOCKS5, switch the proxy to SOCKS5 on your order and use socks5://HOST:PORT with the port the order then shows.

Does the IP whitelist work with SOCKS5?

Yes. A whitelisted address is accepted without credentials over HTTP and over SOCKS5, which is what makes SOCKS5 usable from Chrome, since Chrome cannot send a SOCKS5 username and password. The whitelist is set through the API or the MCP server and takes IPv4 addresses. SOCKS5

Can each browser in a test suite use a different proxy?

Yes, one per driver: the proxy is part of the options a driver starts with, so two drivers can use two addresses. Changing the proxy of a running Chrome is not possible; start a new driver instead.

Will a long suite switch addresses halfway through?

It will not. The driver keeps the address it started with until it quits, and the address itself stays assigned to you for the whole billing period. Suites that need many origins at once would need a pool that changes them, and that is not on sale yet.

What can I use the proxy for?

End-to-end tests of your own product, regional checks of your storefront, ad verification, price research and brand protection all run without prior review under our acceptable use policy. Driving a browser to defeat CAPTCHAs, bot defences, rate limits or account bans is a different matter: the address does not do it, and the policy prohibits attempting it. Acceptable Use Policy

A static address keeps browser tests repeatable: the same suite, run next week, arrives from the same place, so a change in the result comes from the site. Order an address on ISP proxies, see pricing, and set the same address in plain HTTP calls with the Python requests guide.

Sources