Sitemap

Proxy Setup for Selenium (Python Automation Guide)

Stop getting blocked: the exact proxy setup that makes Selenium automation actually work

--

Press enter or click to view image in full size
selenium proxy python setup guide

To set up a proxy in Selenium with Python, create ChromeOptions, add the proxy server using --proxy-server, then launch Chrome with those options. For authenticated proxies, Selenium usually needs a Chrome extension or another authentication workaround. To avoid blocks, use clean proxies, rotate IPs carefully, add delays, and reduce Selenium detection signals.

You run your script.
It works… for a while.

Then suddenly:

  • Requests slow down
  • Pages stop loading
  • CAPTCHAs appear
  • Everything dies

That’s not a coding issue. That’s your IP getting flagged.

Here’s What’s Really Happening

Websites don’t care how clean your code is.

They’re watching:

  • Your IP address
  • Your request frequency
  • Your browser behavior

And if you’re not using proxies correctly?

You’re done before you even scale.

The Fix Most People Miss

Setting a proxy isn’t enough.

You need:

  • Proper configuration
  • Authentication handling
  • IP rotation
  • Anti-detection tweaks

Miss even one and your automation fails.

This guide shows you exactly how to do it right.

Step-by-Step Selenium Proxy Setup

Step 1: Basic Proxy (No Authentication)

Start simple. Get this working first.

from selenium import webdriver

proxy = "123.45.67.89:8080"

options = webdriver.ChromeOptions()
options.add_argument(f'--proxy-server=http://{proxy}')

driver = webdriver.Chrome(options=options)
driver.get("https://httpbin.org/ip")

If the IP shown isn’t yours , you’re good.

Step 2: Authenticated Proxy (Where Most People Fail)

Most real proxies require:

  • Username
  • Password

Here’s the problem:

Get ProxiesThatWork’s stories in your inbox

Join Medium for free to get updates from this writer.

Selenium doesn’t support this natively.

So you need a workaround.

👉 Inject a Chrome extension:

import zipfile

def create_proxy_auth_extension(host, port, user, password):
manifest = """{
"version": "1.0.0",
"manifest_version": 2,
"name": "ProxyAuth",
"permissions": ["proxy","tabs","storage","<all_urls>","webRequest","webRequestBlocking"],
"background": {"scripts": ["background.js"]}
}"""

background = f"""
chrome.proxy.settings.set({{
value: {{
mode: "fixed_servers",
rules: {{
singleProxy: {{
scheme: "http",
host: "{host}",
port: parseInt({port})
}}
}}
}},
scope: "regular"
}}, function() {{}});

chrome.webRequest.onAuthRequired.addListener(
function() {{
return {{authCredentials: {{username: "{user}", password: "{password}"}}}};
}},
{{urls: ["<all_urls>"]}},
["blocking"]
);
"""

plugin = "proxy_auth.zip"
with zipfile.ZipFile(plugin, "w") as zp:
zp.writestr("manifest.json", manifest)
zp.writestr("background.js", background)

return plugin

Use it:

plugin = create_proxy_auth_extension("host", "port", "user", "pass")

options = webdriver.ChromeOptions()
options.add_extension(plugin)

driver = webdriver.Chrome(options=options)

Step 3: Rotate or Get Blocked

Static proxies are a dead end.

import random

proxies = [
"ip1:port",
"ip2:port",
"ip3:port"
]

proxy = random.choice(proxies)

To avoid bans, use clean HTTP proxies that aren’t already abused or blacklisted.

Step 4: Reduce Detection (Critical)

Even with proxies, Selenium is detectable.

options.add_argument("--disable-blink-features=AutomationControlled")

Better:

  • Use undetected-chromedriver
  • Add delays
  • Mimic human behavior

Want to Scale This?

If you’re serious about automation, you need proper rotation logic.

This guide breaks it down clearly:

👉 Stop Getting Blocked: How to Rotate Proxies in Python for Web Scraping (Beginner Guide)

The Winning Setup

If you want scripts that actually survive:

  • Rotating proxies
  • Authentication support
  • Anti-detection tweaks

That’s it.

Final Thoughts

Most people blame Selenium.

Wrong move.

The real issue is:

  • Bad proxies
  • No rotation
  • Weak setup

Fix those and your automation stops failing.

If you want consistent results, stick with proxies that work, not whatever you find on random lists.

--

--

ProxiesThatWork
ProxiesThatWork