Geonode logo
Developer, scraping & anti-detect tools

Selenium Proxy Setup for Chrome, Firefox and Proxies with a Password

Selenium works on

  • Windows
  • macOS
  • Linux

Key facts

  • Set it in one line

    Chrome and Edge: options.add_argument("--proxy-server=http://HOST:PORT"). Firefox: the network.proxy.* preferences. A proxy with a password also needs the BiDi auth handler.

  • One proxy per session

    Selenium passes the proxy to the browser when the driver starts. To switch to a different proxy, call driver.quit() and start a new driver with new options.

  • Selenium Grid

    Grid sends the proxy settings to the node as a capability, and the browser on the node opens the connection. That means the node machine has to reach the proxy host. A firewall rule that only lets your laptop through won't help.

  • Driver downloads have their own proxy setting

    Selenium Manager (4.6+) downloads chromedriver and geckodriver itself. It uses a proxy set through the Proxy class (options.proxy), but not one passed as --proxy-server. If the download fails with "error sending request" behind a corporate proxy, set SE_PROXY or the proxy key in se-config.toml.

Proxy protocols Selenium can use

Selenium only hands the proxy settings to the browser. The browser makes the connection, so its limits are the ones that count.

NameWorks InAuthBlocking ResistanceBest ForWhere To Get
HTTP / HTTPSChrome, Edge and Firefox through --proxy-server, the Proxy class or Firefox preferencesUsername and password through the BiDi auth handler; Chrome ignores user:pass inside --proxy-serverSet by the IP type (residential, ISP or datacenter)The default for paid proxies with a username and passwordGeonode residential, ISP or datacenter proxies; Geonode free list
SOCKS5Chrome and Edge with socks5://HOST:PORT; Firefox with network.proxy.socks preferencesNone in Chrome and Edge: Chromium ignores SOCKS5 usernames and passwordsSame as HTTPProxies without a password, or IP-allowlisted SOCKS5 portsGeonode residential or ISP proxies; Geonode free list
SOCKS4Chrome and Edge with socks4://HOST:PORT; Firefox with network.proxy.socks_version set to 4None: SOCKS4 has no password fieldSame as HTTPTesting scripts with free SOCKS4 proxiesGeonode free list

Which proxy type to use with Selenium

Sites with bot protection look at the IP type as well as the browser. Headless Chrome on a datacenter IP fails both checks more often.

Best for Selenium

Residential proxies

from $0.27/GB

Residential IPs pass IP-type checks on protected sites, and you can pick the country when testing a localized page.

Logged-in test flows

ISP proxies

from $1.25/IP

The IP stays fixed, so a test that signs in and runs for hours keeps one address and one session.

Unprotected sites

Datacenter proxies

from $0.14/GB

Fine for your own staging servers and sites that do not block datacenter ranges.

Script testing only

Free public proxies

Free

Many are slow or already offline. Use one to check that your proxy code runs, and keep real runs and logins off them.

How to set up a proxy in Selenium

The examples are in Python with Selenium 4. Have the proxy host and port ready, plus the username and password if the proxy is paid.

  1. Install or update Selenium with pip install -U selenium. Selenium Manager fetches a matching chromedriver, so no PATH setup is needed.

  2. Import the package with from selenium import webdriver.

  3. Create the options with options = webdriver.ChromeOptions(). For Edge, use webdriver.EdgeOptions().

  4. Add the proxy with options.add_argument("--proxy-server=http://HOST:PORT"). For SOCKS5, write socks5://HOST:PORT instead.

  5. To skip the proxy for some hosts, add options.add_argument("--proxy-bypass-list=localhost;staging.example.com").

  6. Or use the Proxy class: from selenium.webdriver.common.proxy import Proxy, then options.proxy = Proxy({"proxyType": "MANUAL", "httpProxy": "HOST:PORT", "sslProxy": "HOST:PORT", "noProxy": "localhost"}). Selenium Manager also downloads the driver through this proxy.

  7. Start the browser with driver = webdriver.Chrome(options=options).

  8. Open a page with driver.get(url) and close the browser with driver.quit() at the end.

Check detailed instructions on our blog:

Read the blog post

How to check that the proxy works

  1. Run driver.get("https://geonode.com/what-is-my-ip") and read the IP on the page. It should be the proxy's IP, not your own.

  2. Open an HTTP page and an HTTPS page in the same session and compare the IPs. Both must show the proxy.

  3. If you set a country in the username, check that the page shows that country.

How to turn the proxy off

  1. Remove the --proxy-server argument, the options.proxy line or the network.proxy preferences, then start a new driver.

  2. To skip the proxy only for some hosts, such as localhost or your staging server, list them in noProxy on the Proxy class, or in --proxy-bypass-list if you use --proxy-server.

Common Selenium proxy problems and fixes

  • Chrome shows a sign-in dialog and the script hangs

    Cause
    The proxy needs a password and Chrome does not read user:pass from --proxy-server
    Fix
    Remove the credentials from the argument and answer the login with driver.network.add_auth_handler after turning on enable_bidi. If the handler doesn't catch the proxy's 407 response, allowlist your IP in the proxy dashboard and drop the password.
  • HTTPS pages show your real IP

    Cause
    The Proxy class or Firefox preferences set only the HTTP proxy, so HTTPS traffic goes direct
    Fix
    Set sslProxy (or network.proxy.ssl and network.proxy.ssl_port in Firefox) to the same host and port as the HTTP proxy.
  • Chrome fails with a proxy or tunnel connection error

    Cause
    Chrome reports ERR_PROXY_CONNECTION_FAILED or ERR_TUNNEL_CONNECTION_FAILED. Wrong host or port, the proxy is offline, or the scheme does not match the port, for example http:// on a SOCKS5 port
    Fix
    Check the host, port and scheme against your proxy dashboard, then test the proxy in the Geonode proxy checker. If it fails there too, the problem is the proxy and your script is fine.
  • Chrome can't connect to a SOCKS5 proxy with a password

    Cause
    Chrome reports ERR_SOCKS_CONNECTION_FAILED because Chrome and Edge do not send SOCKS5 usernames and passwords
    Fix
    Switch to the provider's HTTP port and use the BiDi auth handler, or use Firefox for that proxy.

More for Selenium users

Selenium proxy FAQ

In Chrome, add options.add_argument("--proxy-server=http://HOST:PORT") to ChromeOptions and start the driver with those options. In Firefox, set network.proxy.type to 1 and fill the network.proxy.http and network.proxy.ssl preferences.

Chrome ignores credentials in --proxy-server. In Selenium 4.32 or later for Python, set enable_bidi to True and call driver.network.add_auth_handler(username, password) after the driver starts.

It is the proxy that the Selenium-controlled browser sends its traffic through. Common uses are scraping from other IPs and testing pages from other countries. It can also get the browser through a corporate firewall. Selenium doesn't ship a proxy of its own.

Set the proxy in the browser options on the client, exactly as you would for a local driver. Grid passes it on to the node, so the node machine needs to reach the proxy host.

Yes. Use --proxy-server=socks5://HOST:PORT in Chrome or Edge, or the network.proxy.socks preferences in Firefox. Chrome and Edge cannot send a SOCKS5 username and password.

Selenium has no rotation of its own. Start a new driver for each proxy, or point one driver at a rotating gateway that changes the IP for you. When a flow must keep one IP, use a Geonode sticky session: set the session lifetime in the username, from 3 minutes up to 24 hours (1440 minutes).