How to use a mobile proxy with selenium (the authenticated proxy trick)
You wired a mobile proxy into selenium, ran your script, and chrome just froze on a login box your code cannot touch. No error you can catch, no field your driver can fill, just a hang that ends in a timeout. This is the most common wall people hit when they put a real proxy behind a browser, and it is not your code being wrong.
I run a hardware proxy farm in Singapore, real phones on real sim cards from Singtel, M1, and StarHub, and I point selenium at these proxies every day. So I have hit this exact wall more times than I can count, and I know which fixes actually hold up in production instead of breaking on the next chrome update.
why the dialog happens
When you launch chrome through selenium and pass the proxy server flag, you can give it a host and a port. You cannot give it a username and a password. There is no flag for that.
So when the proxy needs auth, chrome does the only thing it knows. It pops up a native login dialog and waits. That dialog lives outside the page, in the browser chrome itself, not in the dom. Your driver can click anything inside a web page, but it cannot type into that box. The script hangs, then it times out.
Do not try to fight the dialog directly. People reach for tools that grab the os window, or script mouse clicks at fixed pixels, or paste in some old keyboard trick. All of it is fragile, it breaks on the next update, and it falls apart the moment you run headless where there is no window to click at all. The real move is to make sure the dialog never appears.
fix one: ip allowlisting (no auth at all)
This is the cleanest option by a mile. If your provider lets you allowlist an address, you register your server’s outbound ip in the dashboard once. After that the gateway trusts the source, so it asks for no username and no password.
That means your selenium code only ever sets host and port:
opts.add_argument("--proxy-server=http://gw.singaporemobileproxy.com:8001")
No credentials anywhere, nothing to leak into a repo, no dialog. The catch is you need to control the server’s ip and it has to be stable, so this is the move for a fixed box or a vps, not a laptop that hops between networks. Find the right address from the exact machine that will use the proxy, because your laptop and your server almost certainly go out through different addresses:
# run this ON the box that will use the proxy
curl -s https://api.ipify.org
Paste that into the allowlist, save, and the box connects clean from then on.
fix two: an auth extension that injects credentials
When you do not control the server ip and you have to use a username and password, the production fix is a tiny browser extension that answers the prompt for you. You build it on the fly, it holds the credentials, and chrome’s auth listener fires them the moment the prompt would appear. You load it when you start the driver and the dialog never shows.
The nice part is you build it fresh per run, so you can drop a different username in each time. That matters for sticky sessions, where the username carries the session token, so one driver gets one extension with one identity baked in. One gotcha: some stealth setups strip extensions, so if you run an undetected driver, confirm the extension actually loaded before you trust it.
fix three: a local upstream that holds the auth
The third option is a small proxy running on localhost that knows the username and password and forwards your traffic up to the real mobile gateway. You point selenium at that local address with no auth at all, because the hard part now lives in the upstream, not the browser.
opts.add_argument("--proxy-server=http://127.0.0.1:3128")
This is the most browser agnostic of the three. Chrome, firefox, anything, they all just talk to localhost and stay dumb. The tradeoff is one more process to start and watch, so I reach for it when the fleet is big enough that holding the auth in a single place is worth it.
verify the exit ip from inside the driver
Never assume the proxy took. Have the driver itself visit an ip echo page and read the body, so you confirm the browser is going out the tunnel, not just your shell:
driver.get("https://api.ipify.org?format=json")
print(driver.page_source)
If it comes back as a Singapore address on Singtel, M1, or StarHub, you are out the right door. If it comes back as your own home or office address, the proxy flag never took, and you go check the host and port before trusting a single result.
dns and socks5h
One thing that quietly bites people is dns. Your traffic can go through the proxy while the name lookups still go out over your own connection, which leaks where you really are. If you use a socks5 proxy, ask for socks5h, not plain socks5. The h tells the client to resolve names at the proxy, through the tunnel, instead of locally.
sticky session per driver, clean profile every time
Keep one driver on one exit ip for its whole run. A sticky session means the site sees one steady visitor instead of an address that jumps mid task, and you usually get it by baking a session token into the proxy username and keeping that token stable for the life of the driver.
And do not reuse a dirty profile. If you point a fresh driver at an old chrome profile, it drags along cookies and logins tied to a different ip, and now your new mobile address is wearing yesterday’s fingerprint. Start each session from a clean profile so the ip and the browser tell the same story.
the errors you will actually see
Three show up again and again. The credential dialog freezing your run means auth is not being handled, so reach for one of the three fixes. A dns leak, where your real location shows up, points at plain socks5 instead of socks5h. And instant flagging on a clean ip is profile reuse, where the old profile gave you away.
the whole thing
Chrome under selenium will not take a password in a flag, so you sidestep the dialog with allowlisting, an auth extension, or a local upstream. Then you verify the exit ip from inside the driver, fix dns with socks5h, keep a sticky session, and start from a clean profile.
If you want to run this on a real Singapore connection, there is a free trial of Singapore Mobile Proxy, real sg mobile ips, sticky sessions, and dns that routes through the tunnel, all from my own hardware farm. Use code YT30 for a discount on your first month.
Get new guides and videos first — join the Telegram channel.