Setting up a proxy with Selenium in Python looks like a one-line job: pass --proxy-server to Chrome and you're done. That works for proxies without a password. The moment your proxy needs a username and password, which every paid rotating proxy does, Chrome either shows a login popup that Selenium can't click or fails with ERR_NO_SUPPORTED_PROXIES. This guide explains why and walks through two setups that work reliably.
The Basic Selenium Proxy Setup (No Authentication)
For a proxy that doesn't need credentials, or one that authorises your machine's IP, the Chrome flag is all you need:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=http://203.0.113.10:8080')
driver = webdriver.Chrome(options=options)
driver.get('https://api.ipify.org')
print(driver.find_element('tag name', 'body').text)
driver.quit()The printed IP should be the proxy's, not yours. If it isn't, check that you didn't start Chrome with an existing profile that has its own proxy settings.
Why Chrome Ignores user:pass in --proxy-server
Chrome's command-line proxy flag only accepts scheme, host and port. Anything like http://user:pass@host:8080 is either stripped or rejected. Chrome expects credentials to come from the browser's auth prompt or from an extension that answers the proxy's 407 challenge. Selenium can't type into that native prompt, so you need something that supplies the credentials for you.
Option 1: A Small Chrome Extension That Answers the Auth Challenge
This is the most portable approach because it uses only Selenium and Chrome. Create a folder called proxy_auth with two files. First, manifest.json:
{
"manifest_version": 3,
"name": "proxy-auth",
"version": "1.0",
"permissions": ["webRequest", "webRequestAuthProvider"],
"host_permissions": ["<all_urls>"],
"background": { "service_worker": "background.js" }
}Then background.js, which hands the credentials to Chrome whenever the proxy asks for them:
chrome.webRequest.onAuthRequired.addListener(
(details, callback) => {
if (!details.isProxy) return callback({});
callback({
authCredentials: {
username: 'USERNAME-country-us',
password: 'PASSWORD'
}
});
},
{ urls: ['<all_urls>'] },
['asyncBlocking']
);Now load it and point Chrome at the gateway:
import os
from selenium import webdriver
ext_dir = os.path.abspath('proxy_auth')
options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=http://global.nodeproxies.xyz:8080')
options.add_argument(f'--load-extension={ext_dir}')
driver = webdriver.Chrome(options=options)
driver.get('https://api.ipify.org')
print(driver.find_element('tag name', 'body').text)
driver.quit()One catch: since Chrome 137, regular branded Chrome builds ignore --load-extension. Run this against Chrome for Testing or Chromium instead. Setting options.browser_version = "stable" makes Selenium Manager download Chrome for Testing for you.
One caveat: recent branded Google Chrome builds ignore --load-extension. If the extension doesn't load, run the script against Chrome for Testing or Chromium, which still honour the flag. You'll know it failed because the page hangs on an auth prompt or returns a 407.
Option 2: Authenticated Proxies with a Local Forwarder
If you can't load extensions, run a tiny local proxy that has no password and forwards everything upstream with your credentials attached. Chrome talks to 127.0.0.1 without auth, and the forwarder handles the 407. Any forwarding proxy that supports an authenticated upstream works; the Selenium side then looks exactly like the basic example above with --proxy-server=http://127.0.0.1:3128. The upside is that it also works for headless Chrome in CI. The downside is one more process to manage.
You may also see the older selenium-wire package recommended for this. It works by intercepting traffic, but it is no longer maintained, so treat it as a legacy option rather than something to build new projects on.
Rotating vs Sticky IPs in Selenium
A browser session makes dozens of requests per page: HTML, scripts, images, API calls. With a rotating proxy and no session parameter, each of those can leave from a different IP, which breaks logins and makes some sites suspicious. For browser automation you almost always want a sticky session for the life of the driver:
import uuid
session_id = uuid.uuid4().hex[:8]
username = f'USERNAME-country-us-session-{session_id}-time-15'Generate the username in Python and write it into background.js before launching, or template the extension folder per driver. A new session id gives a new IP; the same id keeps the same IP for up to 15 minutes. The difference is covered in more depth in rotating vs sticky proxies with Python and Playwright.
Running Several Drivers with Different IPs
- Give each driver its own extension folder (or its own forwarder port) with a different session id.
- Use a separate --user-data-dir per driver so cookies don't leak between sessions.
- Keep concurrency modest. Ten browsers is already a lot of RAM, and the proxy isn't your bottleneck.
- Close drivers in a finally block. Orphaned Chrome processes keep using bandwidth on pages with live connections.
Troubleshooting
- ERR_NO_SUPPORTED_PROXIES: you put credentials inside --proxy-server. Remove them and use one of the options above.
- A 407 page or endless auth popup: the extension didn't load, or the username/password is wrong. See how to fix proxy error 407.
- ERR_TUNNEL_CONNECTION_FAILED: the proxy connected but couldn't reach the target. Retry with a new session id.
- Your real IP shows up: Chrome started with a profile or policy that overrides the flag. Use a fresh --user-data-dir.
Using Selenium with NodeProxies
Use HTTP at global.nodeproxies.xyz:8080 as the --proxy-server value and put your options in the username, for example USERNAME-country-us-session-run1-time-15. Residential proxies are the usual choice for browser automation on protected sites, while datacenter proxies are cheaper for internal testing. You can create an account with a $3 minimum deposit and no ID check, then check current pricing.
FAQ
Can I pass a username and password in Selenium's --proxy-server argument?
No. Chrome drops credentials from that flag. Use an extension that answers the auth challenge, or a local forwarder without a password.
Does Selenium support SOCKS5 proxies?
Chrome accepts --proxy-server=socks5://host:port, but it doesn't support SOCKS5 username/password authentication, so for authenticated proxies use the HTTP port instead.
How do I get a new IP for each Selenium session?
Use a new session id in the proxy username for each driver. Each new id is assigned a new IP, and the same id keeps its IP until the session time runs out.
Does headless Chrome use the proxy the same way?
Yes. The --proxy-server flag and the extension approach both work in Chrome's new headless mode.
