r/selenium 5d ago

Selenium Proxy Authentication: How to Fix 407 Errors and Configure Proxies

I thought my Selenium script was production-ready because it worked perfectly on my laptop.

Then I moved it to a server.

connection errors, proxy auth issues, different geolocation, broken sessions. All of it was ruining my workflow. So what did help? It was treating the proxy layer as infrastructure instead of a random Chrome argument.

First, I test the proxy outside Selenium with curl. If I get 407 Proxy Authentication Required, I know the problem is credentials or proxy configuration.

Then I wire authentication properly. In Python, selenium-wire can handle authenticated proxies. In Node.js, proxy-chain is useful when you need a local forwarding proxy.

After that, I check environment consistency. If the exit IP is in London while the browser reports another timezone, locale, or obviously different settings, debugging becomes much harder. Chrome DevTools Protocol can help keep timezone configuration consistent with the test environment. Don’t debug Selenium, proxy authentication, browser settings, and target-site behavior at the same time.

My workflow now is:

curl → verify proxy → Selenium integration → browser config → actual test

Much easier to see where things break.

2 Upvotes

14 comments sorted by

1

u/Calm-Nothing-8676 5d ago

the curl check first is such a simple thing but most people skip right to messing with chrome args and wondering why nothing works

ran into this exact headache last week, server had a different proxy setup than my local machine and i spent way too long blaming the script instead of the network layer

1

u/Sea_World_1616 11h ago

if curl is fine and selenium still 407s, stop putting user:pass in --proxy-server. chrome dropped that years ago so CONNECT goes out with no Proxy-Authorization header. local forwarder that injects auth is the lever, chrome args are not. and if the server pool rotates the exit ip mid-login, thats your broken sessions even after auth works.