Selenium Change Proxy Per Session or Per Tab: What Works
What Selenium can switch, what it cannot, and a pattern for giving every session its own proxy.
What Selenium can switch
In Selenium's documentation the proxy is set on the options object (options.proxy, or a Chrome argument) before webdriver.Chrome() is called, and every example works that way. There is no command in that setup to change it for a single tab or to swap it in a running browser. In practice "change the proxy" means "start the next session with another proxy".
Chrome itself has an experimental DevTools call, Target.createBrowserContext, that accepts a proxyServer for a new empty context. It is not part of Selenium's API, we did not test driving such a context with Selenium window commands, and we do not recommend building on it. Playwright and Puppeteer expose per-context proxies as normal options.
Quit the browser, start the next with another proxy
Sequential jobs, one IP per job
Start-up time per session; use a clean profile each time
Parallel drivers
Several browsers at once, each with its own proxy and local port
Workers that must run side by side
Memory per browser; one forwarder per proxy if the login is SOCKS5
Rotating gateway
One proxy address; a new connection gets a new IP
Many one-off requests without restarting
Not a switch per tab: Chrome reuses open connections, see below
Per-context proxy
Playwright or Puppeteer, proxy on the context
Many isolated sessions in one browser
A different tool; the Selenium page stays for existing tests
Source: Selenium documentation (driver options), Chrome DevTools Protocol and Playwright documentation, read on 13 November 2026; gateway behaviour from the Proxy302 product facts file.
# pip install -U selenium and install gost (see gost.run)
import socket, subprocess, tempfile, time
from selenium import webdriver
from selenium.webdriver.common.by import By
PROXIES = [ # one entry per IP, copied from My assets (SOCKS5 endpoints)
("HOST", "PORT", "LOGIN_1", "PASSWORD_1"),
("HOST", "PORT", "LOGIN_2", "PASSWORD_2"),
]
def start_forwarder(local_port, host, port, login, password):
proc = subprocess.Popen(["gost", "-L", f"socks5://127.0.0.1:{local_port}",
"-F", f"socks5://{login}:{password}@{host}:{port}"])
for _ in range(50):
try:
socket.create_connection(("127.0.0.1", local_port), timeout=0.2).close()
return proc
except OSError:
time.sleep(0.2)
proc.terminate()
raise RuntimeError("forwarder did not start")
def run_session(local_port, entry):
forwarder = start_forwarder(local_port, *entry)
options = webdriver.ChromeOptions()
options.add_argument(f"--proxy-server=socks5://127.0.0.1:{local_port}")
options.add_argument(f"--user-data-dir={tempfile.mkdtemp()}") # a clean profile per session
driver = webdriver.Chrome(options=options) # the proxy is fixed from here on
try:
driver.get("https://ipinfo.io/json")
print(entry[2], driver.find_element(By.TAG_NAME, "body").text)
finally:
driver.quit()
forwarder.terminate()
for i, entry in enumerate(PROXIES):
run_session(1080 + i, entry) # next proxy = next browser session
Example only: replace HOST, PORT, LOGIN and PASSWORD with the values from My assets. Chrome cannot send a SOCKS5 login itself, so the example puts a local forwarder in front of each proxy.
Setting the proxy with Selenium's Proxy class
from selenium import webdriver
from selenium.webdriver.common.proxy import Proxy, ProxyType
proxy = Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy.socks_proxy = "127.0.0.1:1080" # the local forwarder, no login in the address
proxy.socks_version = 5
options = webdriver.ChromeOptions()
options.proxy = proxy # set before the browser starts
driver = webdriver.Chrome(options=options)
Example only: the proxy is part of the options, so it applies to the whole session that starts from them.
A new IP without a new browser
With Proxy302 rotating residential or datacenter proxies and no session set, each new connection gets a new IP, not each request: a connection that stays open (keep-alive) keeps its IP. Chrome reuses open connections, so consecutive page loads in one browser may show the same IP for a while.
If a job needs a guaranteed new IP, start a new browser session. If it needs the same IP for a long time, use a static IP or open a session of the length you need.
Decide what must stay constant: one IP per job, one per account, or a new one per request.
Step 2
One IP per job or per account: use a static IP and one browser session per IP. A fresh profile per session keeps cookies apart.
Step 3
New IP per request and no need for a fixed address: use a rotating proxy and expect connection reuse inside one browser.
Step 4
Many isolated sessions at once: move that part of the work to a tool with per-context proxies.
Common problems
The second session still shows the first IP
Check The old browser or its forwarder is still running, or both sessions use one profile.
Fix Call driver.quit() and terminate the forwarder in a finally block, and give each session its own --user-data-dir.
IP does not change between page loads on a rotating proxy
Check Chrome kept an open connection, which keeps its IP.
Fix Start a new session when you need a new IP, or use a static IP per session.
Every session shows your own IP
Check The proxy flag or Proxy object was not passed to the options that created the driver.
Fix Check the options object given to webdriver.Chrome, and test the proxy with curl first.
Stop when If curl through the proxy also fails, the problem is the address or login, not Selenium.
Proxy with a SOCKS5 login fails in Chrome
Check Chromium cannot send a SOCKS5 login.
Fix Put a local forwarder in front, as in the example, or use the HTTP endpoint.
How to do it with Proxy302
For one fixed address per session, a static ISP IP costs US$0.50 for 1 day or US$7.99 for 30 days (about US$0.27 a day), does not rotate during the lease, and up to 100 can be bought in one order. For a pool of changing IPs, rotating residential on the Budget line costs US$1.50 per GB.
Because Chrome cannot send a SOCKS5 login, give Selenium either the HTTP endpoint (port 2222) or a local forwarder in front of the SOCKS5 endpoint (port 3333). No free trial; the smallest purchase is 1 GB of residential traffic or one IP for one day.
Selenium proxy with username and password in Chrome: HTTP proxy in ChromeOptions plus Selenium's BiDi auth handler, no extensions. Static datacenter IPs for test runs.
Playwright proxy setup with username and password: static datacenter IPs for tests and CI, rotating residential from US$1.50/GB when a site blocks servers.
Real household IPs in 195+ countries; the Premium line adds state and major-city targeting. A new IP on every new connection, or keep sticky sessions. From US$1.50/GB, US$1.35/GB at 100 GB. HTTP and SOCKS5.
Read on 13 November 2026: the Python example builds ChromeOptions, sets options.proxy = Proxy({"proxyType": ProxyType.MANUAL, "httpProxy": "http.proxy:1234"}) and only then starts webdriver.Chrome(options=options); the examples contain no user:pass.
The visible part of the page does not state in so many words that the proxy cannot be changed after the session starts; this guide relies on the examples, where the proxy is always part of the options passed at start.
Read on 13 November 2026 in the protocol JSON: createBrowserContext creates a new empty browser context, similar to an incognito profile; its parameters proxyServer ("similar to the one passed to --proxy-server") and proxyBypassList are marked experimental.
Read on 13 November 2026: the SOCKS5 greeting Chromium sends is 05 01 00 (one method, "no authentication"), so a login cannot be passed to a SOCKS5 proxy from Chrome.
Read on 13 November 2026: proxy can be set globally for the browser or for each browser context individually.
Proxy302 product facts and price list
Product observation · Confirmed on:
Product facts file, checked on 13 November 2026 against the console, backend and price list: static ISP lease prices per IP (US$, 1 PTC = US$1), rotating residential Budget line price per GB, HTTP port 2222 and SOCKS5 port 3333 on proxy.proxy302.com, which protocols work for which product, no free trial.
Ready to try it?
Create an account, top up once, then pick rotating residential, static ISP or datacenter IPs and have one running in your browser within minutes.