Selenium with an authenticated proxy

Chrome ignores a username and password in --proxy-server, and it does not support SOCKS5 authentication at all. Here is what works.

See plans from $75/mo ♡ Read the docs

Option 1: HTTP proxy through selenium-wire (Python)

from seleniumwire import webdriver

opts = {'proxy': {
    'http':  'http://USER:PASS@HOST:PORT',
    'https': 'http://USER:PASS@HOST:PORT',
}}
driver = webdriver.Chrome(seleniumwire_options=opts)
driver.get('https://api.ipify.org')
print(driver.page_source)

Use the HTTP port of your line. selenium-wire answers the proxy login prompt for the browser.

Option 2: a local forwarder without a password

Run a small local proxy that listens on 127.0.0.1 without authentication and forwards to your line with the credentials. Then point Chrome at the local port. This works in every language binding, including Java and C#.

--proxy-server=socks5://127.0.0.1:1080

Option 3: Firefox

Firefox handles proxy settings through preferences, and with an HTTP proxy it can answer the login prompt through an extension or selenium-wire. For SOCKS5 with a password, use the local forwarder approach.

Do not forget

Questions

Why does Chrome show a login popup?

The HTTP proxy asked for credentials and Selenium cannot type into that native dialog. Use one of the options above.

Is Playwright easier?

Yes. Playwright accepts proxy username and password directly for HTTP proxies.

Related guides

Ready for your own dedicated private mobile proxy? 🎀

Real AT&T, Verizon and T-Mobile SIMs · unlimited data · one-tap IP rotation · delivered by email or Telegram.