Proxies + AI

Mobile Proxy with Selenium in Python

November 2026·8 min read·Selenium 4, Python, Chrome

Selenium hands the proxy to Chrome with a single flag, --proxy-server. The catch: that flag has no place for a username and password, and Chrome won't prompt for them in an automated session. There are two clean ways around it, and this guide shows both with code that runs as written: IP whitelisting (no login at all) and a tiny local forwarder that adds the login for you.

In this guide

  1. Your proxy details
  2. Pick your login method
  3. Option A: IP whitelisting (simplest)
  4. Option B: username and password via a local forwarder
  5. SOCKS5
  6. Verify the IP and city
  7. Timeouts and lighter pages
  8. Example: one script, several cities

1. Your proxy details

Every RelayKit proxy card in the dashboard shows its IP, HTTP port (8000), SOCKS5 port (9000), username and password. The card's 🤖 Use with AI tools button also generates ready-made snippets (Python requests, curl, Playwright, Puppeteer and more), which is a quick way to confirm the proxy works before you add Selenium. Below, the values are placeholders: YOUR_PROXY_IP, USER, PASS.

Shell
pip install -U selenium # Selenium 4 downloads the matching chromedriver itself export PROXY_HOST=YOUR_PROXY_IP PROXY_USER=USER PROXY_PASS=PASS

2. Pick your login method

Things that don't work: --proxy-server=http://USER:PASS@host:8000 (Chrome drops credentials in that flag), and the old "proxy auth extension" trick (current Chrome releases ignore --load-extension). The archived selenium-wire package is also best avoided for new projects.

3. Option A: IP whitelisting (simplest)

On the proxy card, turn on IP Whitelisting and enter the public IP of the machine that runs Selenium (for one address, 1.2.3.4/32). The proxy then accepts connections from that IP without a login, and Chrome only needs the address:

whitelist.py
import os from selenium import webdriver from selenium.webdriver.common.by import By options = webdriver.ChromeOptions() options.add_argument("--headless=new") options.add_argument(f"--proxy-server=http://{os.environ['PROXY_HOST']}:8000") driver = webdriver.Chrome(options=options) try: driver.set_page_load_timeout(60) driver.get("https://api.ipify.org?format=json") print(driver.find_element(By.TAG_NAME, "body").text) # must show the proxy's IP finally: driver.quit()

4. Option B: username and password via a local forwarder

pproxy is a small pure-Python proxy. Run it on your own machine: it listens on 127.0.0.1 without a login and forwards everything to your mobile proxy with the login. Chrome talks to the local port, so it never needs the password.

Shell
pip install pproxy pproxy -l http://127.0.0.1:8080 -r "http://$PROXY_HOST:8000#$PROXY_USER:$PROXY_PASS"

Test it with curl in another terminal, then point Selenium at the local port:

Shell
curl -x http://127.0.0.1:8080 "https://api.ipify.org?format=json"

To keep it all in one script, start the forwarder from Python and stop it when you're done:

forwarder.py
import os, subprocess, sys, time from selenium import webdriver from selenium.webdriver.common.by import By UPSTREAM = f"http://{os.environ['PROXY_HOST']}:8000#{os.environ['PROXY_USER']}:{os.environ['PROXY_PASS']}" LOCAL = "127.0.0.1:8080" fwd = subprocess.Popen([sys.executable, "-m", "pproxy", "-l", f"http://{LOCAL}", "-r", UPSTREAM]) time.sleep(1.5) # give it a moment to start listening options = webdriver.ChromeOptions() options.add_argument("--headless=new") options.add_argument(f"--proxy-server=http://{LOCAL}") driver = webdriver.Chrome(options=options) try: driver.set_page_load_timeout(60) driver.get("https://api.ipify.org?format=json") print(driver.find_element(By.TAG_NAME, "body").text) finally: driver.quit() fwd.terminate()

Keep the forwarder local. It has no login of its own, so bind it to 127.0.0.1 as shown, never 0.0.0.0, or anyone on your network could use your proxy. If your password contains #, @ or:, use IP whitelisting instead.

5. SOCKS5

RelayKit proxies also answer on SOCKS5 port 9000. Chrome can't log in to a SOCKS5 proxy itself, so it's the same two options:

Whitelist mode: Chrome straight to SOCKS5
options.add_argument(f"--proxy-server=socks5://{os.environ['PROXY_HOST']}:9000")
Username/password: forwarder in front of SOCKS5
pproxy -l http://127.0.0.1:8080 -r "socks5://$PROXY_HOST:9000#$PROXY_USER:$PROXY_PASS" # Selenium keeps using --proxy-server=http://127.0.0.1:8080

For most browser work the HTTP port is all you need; it carries HTTPS sites without any problem.

6. Verify the IP and city

Check where the browser is before the real work and stop if it isn't on the proxy:

verify.py
import json from selenium.webdriver.common.by import By def where_am_i(driver): driver.get("https://ipapi.co/json/") info = json.loads(driver.find_element(By.TAG_NAME, "body").text) return {"ip": info.get("ip"), "city": info.get("city"), "region": info.get("region"), "org": info.get("org")}

Mobile IPs aren't static: Reset IP, an auto-rotation timer or a city switch gives you a new one. Compare the city (and that org is the mobile carrier) rather than one exact IP.

7. Timeouts and lighter pages

8. Example: one script, several cities

With a RelayKit Multi-Location proxy one proxy covers many US cities. Run the script, move the proxy to another city on its card, copy the new details from the card into your environment (a move connects you to a modem in the new city, so they change), and run again. Each run logs the city it actually came from:

city_check.py
import json, os, subprocess, sys, time from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC TARGET = "https://example.com/pricing" # the page you're researching PRICE_SELECTOR = ".price" # adjust to the site upstream = f"http://{os.environ['PROXY_HOST']}:8000#{os.environ['PROXY_USER']}:{os.environ['PROXY_PASS']}" fwd = subprocess.Popen([sys.executable, "-m", "pproxy", "-l", "http://127.0.0.1:8080", "-r", upstream]) time.sleep(1.5) options = webdriver.ChromeOptions() options.add_argument("--headless=new") options.add_argument("--proxy-server=http://127.0.0.1:8080") driver = webdriver.Chrome(options=options) try: driver.set_page_load_timeout(60) driver.get("https://ipapi.co/json/") where = json.loads(driver.find_element(By.TAG_NAME, "body").text) driver.get(TARGET) WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.CSS_SELECTOR, PRICE_SELECTOR))) prices = [el.text for el in driver.find_elements(By.CSS_SELECTOR, PRICE_SELECTOR)] row = {"city": where.get("city"), "region": where.get("region"), "ip": where.get("ip"), "prices": prices, "at": time.time()} with open("prices.jsonl", "a") as f: f.write(json.dumps(row) + "\n") print(row) finally: driver.quit() fwd.terminate()

Only collect what you're allowed to: respect each site's terms and robots rules, keep request rates modest, and use the data for your own research, price monitoring and QA. For Java and the other frameworks side by side, see proxies with Selenium, Puppeteer and Playwright.

Selenium on a dedicated US mobile IP

Real Verizon 4G/5G carrier IPs, unlimited data, HTTP and SOCKS5, IP whitelisting, and a Multi-Location plan that switches US cities from the dashboard.

See the Multi-Location proxy →

Related guides