Skip to content
seamless

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 a local forwarder that adds the credentials.

Setup

Set up Selenium in 5 steps

  1. 01

    Install Selenium

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

    pip install selenium
  2. 02

    Start a local forwarder

    Chrome ignores credentials in --proxy-server and shows a native dialog Selenium cannot dismiss. Run a small local forwarder on 127.0.0.1 that adds your username and password upstream. Replace PROXY_HOST, PROXY_PORT, USERNAME and PASSWORD with the endpoint and credentials shown in your seamless dashboard.

    # 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
  3. 03

    Point Chrome at the forwarder

    Chrome now talks to localhost without credentials and the forwarder handles authentication. The full walkthrough, including a DevTools alternative, is in our Selenium proxy authentication guide.

    from selenium import webdriver
    
    options = webdriver.ChromeOptions()
    options.add_argument("--proxy-server=http://127.0.0.1:8080")
    
    driver = webdriver.Chrome(options=options)
    driver.get("https://example.com")
  4. 04

    Or use Firefox

    Firefox takes its proxy from preferences on the options object. It cannot accept credentials this way either, so point it at the same local forwarder.

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

    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)

FAQ

Questions about Selenium proxies

Anything else? Our team answers on live chat, by email and on Discord.

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 approach is a local forwarder on 127.0.0.1 that adds the credentials upstream, so the browser itself connects without any. 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.

Start small. Scale when it works.

Buy a little bandwidth or rent a single ISP proxy for a day, test it on your own targets, then grow from there.