Skip to content
Browser automation

How to use proxies with Selenium

Selenium routes traffic through a proxy via browser options — a --proxy-server argument for Chrome or a configured Proxy object. Chrome ignores credentials in that flag, so authenticated proxies need either IP whitelisting or a local forwarder that adds the credentials.

Recommended for Selenium

ISP proxies — Selenium is often used for logged-in account work, which needs one stable, trusted IP rather than a rotating pool — and IP whitelisting avoids the Chrome authentication problem entirely.

See isp proxies

Setup

  1. 1

    Install Selenium

    Install the bindings; recent versions manage the driver binary for you.

    pip install selenium
  2. 2

    Set the proxy on Chrome

    Add the proxy as a Chrome argument. This works directly when your machine's IP is whitelisted in the dashboard, because no credentials are then required. Replace PROXY_HOST, PROXY_PORT, USERNAME and PASSWORD with the endpoint and credentials shown in your seamless dashboard.

    from selenium import webdriver
    
    options = webdriver.ChromeOptions()
    options.add_argument("--proxy-server=http://PROXY_HOST:PROXY_PORT")
    
    driver = webdriver.Chrome(options=options)
    driver.get("https://example.com")
  3. 3

    Handle username and password authentication

    Chrome ignores credentials in --proxy-server and shows a native dialog Selenium cannot dismiss. Whitelisting your IP is the simplest fix; otherwise run a small local forwarder that adds the credentials, and point the browser at it. The full walkthrough is in our Selenium proxy authentication guide.

    # Local relay without auth, forwarding upstream with your credentials
    gost -L http://127.0.0.1:8080 -F http://USERNAME:PASSWORD@PROXY_HOST:PROXY_PORT
    
    # then in Python:
    #   options.add_argument("--proxy-server=http://127.0.0.1:8080")
  4. 4

    Or use Firefox

    Firefox takes its proxy from preferences on the options object. It still cannot accept credentials this way, so combine it with whitelisting or the local forwarder.

    from selenium import webdriver
    
    options = webdriver.FirefoxOptions()
    options.set_preference("network.proxy.type", 1)
    options.set_preference("network.proxy.http", "PROXY_HOST")
    options.set_preference("network.proxy.http_port", PROXY_PORT)
    options.set_preference("network.proxy.ssl", "PROXY_HOST")
    options.set_preference("network.proxy.ssl_port", PROXY_PORT)
    
    driver = webdriver.Firefox(options=options)
  5. 5

    Verify the exit IP

    Confirm the browser is really going through the proxy before you build anything on top of it.

    driver.get("https://api.ipify.org?format=json")
    print(driver.page_source)

Selenium proxy FAQ

How do I use an authenticated proxy in Selenium with Chrome?

Chrome ignores credentials placed in the --proxy-server flag and raises a native authentication dialog that WebDriver cannot interact with. The reliable approaches are whitelisting your machine's IP so no credentials are needed, or running a local forwarder on 127.0.0.1 that adds the credentials upstream. The old extension trick no longer loads in recent branded Chrome builds.

Does Selenium support SOCKS5 proxies?

Yes. Chrome accepts --proxy-server=socks5://host:port, and Firefox can be pointed at a SOCKS proxy through the network.proxy.socks preferences.

Should I use Selenium or Playwright with proxies?

Playwright handles proxy authentication natively and supports a different proxy per browser context, which makes it markedly less awkward for proxy work. Selenium remains the pragmatic choice when you already have an established suite built on it.