Selenium proxy setup
Selenium hands the proxy to the browser, but Chrome and Firefox cannot take a proxy password that way. The reliable route is IP whitelisting, shown here for Chrome and Firefox in Python.
- Python
- Chrome and Firefox
- IP whitelisting
Proxies for Selenium
Lowest rate for each. Every tier is on the pricing page.
Before you start
Three things to have ready.
Selenium
pip install selenium. Recent versions download the matching browser driver for you.
Your proxy line
Copy the host, port, username and password from the generator in your dashboard. The examples use Eternal Residential: et.vantixproxy.com, port 1000.
A fixed IP to whitelist
Whitelisting works best from a machine whose IP does not change, such as a server or an office line.
Step 1: Whitelist the machine that runs Selenium
Find the public IP of the computer or server running your tests, with our What is my IP tool or with curl on a server, and add it to the IP whitelist in your dashboard. The proxy then accepts the browser without a login.
- Whitelist The IP that runs Selenium
- No login No pop-up to handle
- Host and port From the generator
- Fixed IP Whitelisting needs one
Find a server’s IP
curl https://api.ipify.org
Step 2: Chrome and Firefox
Chrome takes the proxy as a start-up argument. Firefox takes it as preferences. Both then send every request through the proxy.
Chrome
from selenium import webdriver
opts = webdriver.ChromeOptions()
opts.add_argument("--proxy-server=http://et.vantixproxy.com:1000")
driver = webdriver.Chrome(options=opts)
driver.get("https://api.ipify.org")
print(driver.find_element("tag name", "body").text)
driver.quit()
Firefox
from selenium import webdriver
opts = webdriver.FirefoxOptions()
opts.set_preference("network.proxy.type", 1)
opts.set_preference("network.proxy.http", "et.vantixproxy.com")
opts.set_preference("network.proxy.http_port", 1000)
opts.set_preference("network.proxy.ssl", "et.vantixproxy.com")
opts.set_preference("network.proxy.ssl_port", 1000)
driver = webdriver.Firefox(options=opts)
Step 3: Need a login or per-session targeting?
Targeting settings live in the password, so they need a login. SeleniumBase, a wrapper around Selenium, accepts a proxy with a username and password. Playwright and Puppeteer do too.
SeleniumBase
from seleniumbase import SB
with SB(proxy="USERNAME:[email protected]:1000") as sb:
sb.open("https://api.ipify.org")
print(sb.get_text("body"))
Troubleshooting and questions
Can I put the login in –proxy-server?
No. Chrome ignores a username and password there. Whitelist your IP, or use SeleniumBase, Playwright or Puppeteer, which send the login for you.
Why does Chrome show ERR_TUNNEL_CONNECTION_FAILED?
The proxy wants a login, which means your IP is not whitelisted, or the machine’s IP has changed. Check the whitelist in your dashboard.
How do I target a country without a login?
Targeting goes in the password, so it needs a login. Use SeleniumBase with a proxy login, as in Step 3.
Why does the IP stay the same across pages?
The browser reuses its connections, and a connection keeps its IP. Start a new driver for a new IP.
Does this work with Selenium Grid or in Docker?
Yes. Whitelist the public IP your Grid nodes or containers use to reach the internet.
Which proxy is best for Selenium?
Budget Residential for scraping and tests at volume. Eternal Residential for occasional runs. Eternal Datacenter for sites that do not block server IPs.
Related guides and tools
More setup guides, and tools to test your proxies.
Get proxies for Selenium
Budget Residential from $0.49/GB, or Eternal Residential from $0.75/GB that never expires. No KYC, crypto or card.