Selenium Java Proxy With Username and Password (BiDi)
The proxy address goes in the options; the username and password go in an authentication handler. Here is why, and the Java for Chrome, Edge and Firefox.
Why the login does not go in the proxy address
Selenium's Proxy class takes host:port for HTTP and SSL; its only username and password fields are for SOCKS v5. Chrome does not use credentials written into proxy settings either, and supports no login method for SOCKS5. So writing http://LOGIN:PASSWORD@HOST:PORT into the flag or into Proxy does not sign in, and a window nobody watches just fails.
The proxy answers with a 407 challenge instead. The WebDriver BiDi specification takes the challenge from Proxy-Authenticate for status 407, so a BiDi authentication handler can answer it. Selenium Java exposes this in its bidi.module.Network class.
import org.openqa.selenium.By;
import org.openqa.selenium.UsernameAndPassword;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.bidi.browsingcontext.BrowsingContext;
import org.openqa.selenium.bidi.browsingcontext.ReadinessState;
import org.openqa.selenium.bidi.module.Network;
import org.openqa.selenium.bidi.network.AddInterceptParameters;
import org.openqa.selenium.bidi.network.InterceptPhase;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions; // for Edge use org.openqa.selenium.edge.EdgeOptions / EdgeDriver
public class ProxyLogin {
public static void main(String[] args) {
ChromeOptions options = new ChromeOptions();
options.enableBiDi(); // the login handler runs over WebDriver BiDi
options.addArguments("--proxy-server=http://HOST:2222"); // no LOGIN:PASSWORD in the address
WebDriver driver = new ChromeDriver(options);
try (Network network = new Network(driver)) {
network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED));
network.onAuthRequired(details ->
network.continueWithAuth(
details.getRequest().getRequestId(),
new UsernameAndPassword("LOGIN", "PASSWORD")));
// open the first page over BiDi, as the Selenium project's own test does
BrowsingContext context = new BrowsingContext(driver, driver.getWindowHandle());
context.navigate("https://api.ipify.org?format=json", ReadinessState.COMPLETE);
System.out.println(driver.findElement(By.tagName("body")).getText()); // the proxy's exit IP
} finally {
driver.quit();
}
}
}
API names checked against the Selenium source on 14 November 2026; the code was not compiled on the writing machine. The same flow in Python was tested on 18 October 2026. Replace HOST, LOGIN and PASSWORD with the values from My assets.
import org.openqa.selenium.Proxy;
import org.openqa.selenium.firefox.FirefoxOptions;
Proxy proxy = new Proxy();
proxy.setHttpProxy("HOST:2222"); // host:port only; Proxy has no login for an HTTP proxy
proxy.setSslProxy("HOST:2222");
FirefoxOptions options = new FirefoxOptions();
options.setProxy(proxy);
options.enableBiDi();
// then create the driver and register the same auth handler as in the Chrome example
Firefox takes the proxy through the standard proxy capability. enableBiDi() exists on FirefoxOptions; Selenium's own auth test is not limited to Chrome, but we have only run the proxy-login flow in Chrome. Not compiled here.
A proxy set in the browser options is passed on to Selenium Manager, which then uses it to download drivers and browsers, without the password. If the first run fails with 407 while downloading a driver, either use the --proxy-server flag for Chrome and Edge, as in the code above, or point Selenium Manager at a different proxy with SE_PROXY. The Proxy302 Python test on 18 October 2026 hit exactly this and avoided it with the flag.
Test the login outside Selenium: curl -x http://LOGIN:PASSWORD@HOST:2222 https://ipinfo.io/json should print the proxy's IP.
Expected result JSON with the exit IP of the proxy.
Step 2
Start the driver with enableBiDi() and the host:port in the flag or in Proxy, with no login in it.
Step 3
Register the handler before the first page and open that page with BrowsingContext.navigate.
Step 4
Print the page body and compare the IP and country with your own.
Expected result The proxy's IP, not yours.
Problems and what to check
The page never loads and the run times out
Check Is the first navigation a classic driver.get() while the proxy waits for a login?
Fix Register the handler first and open the first page with BrowsingContext.navigate; the Python test showed the same stall with a classic get.
407 Proxy Authentication Required
Check Was enableBiDi() called, and is the handler registered before the page opens? Is the login right?
Fix Test with curl, then re-check the order of the calls.
Driver download fails on the first run
Check Is the proxy set through Proxy or options, so Selenium Manager uses it too?
Fix Use the --proxy-server flag on Chrome and Edge, or SE_PROXY, or a driver you already have.
Your own IP shows up
Check Is the address in host:port form and the protocol HTTP on port 2222?
Fix Fix the address, restart the driver and print the exit IP.
Stop when If curl through the same proxy fails too, stop changing Selenium code and check the account details.
Which Proxy302 IP fits Selenium Java
For test runs and grids that do not log in to accounts, a datacenter IP rented per IP costs US$0.25 for 1 day or US$3.99 for 30 days, with up to 100 IPs in one order; choose HTTP, which is port 2222 on proxy.proxy302.com. Datacenter addresses are recognisable as datacenter, so for account or shop work use a static ISP IP, from US$0.50 a day.
There is no free trial; the smallest purchase is one IP for one day.
How do I set a proxy with username and password in Selenium Java?
Put host:port in ChromeOptions (--proxy-server) or FirefoxOptions (Proxy), call enableBiDi(), and answer the login with Network.onAuthRequired and continueWithAuth.
Why did my first run fail with 407 before any page opened?
A proxy in the options is also used by Selenium Manager to download the driver, without the password. Use the flag for Chrome and Edge or set SE_PROXY.
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.
Read on 14 November 2026: setHttpProxy and setSslProxy take host:port; setSocksUsername and setSocksPassword exist and are supported only with SOCKS v5; the class has no login fields for an HTTP proxy.
Read on 14 November 2026: the Java example creates a Proxy, calls setHttpProxy("myproxy.com:8080") and sets it on the options as the "proxy" capability.
Read on 14 November 2026: the interface lets a driver authenticate to a website; ChromeDriver, ChromiumDriver, EdgeDriver and ElectronDriver implement it; the page does not mention proxy authentication.
Read on 14 November 2026 (trunk): Network has addIntercept, onAuthRequired and continueWithAuth(requestId, UsernameAndPassword); InterceptPhase has AUTH_REQUIRED; ChromiumOptions and FirefoxOptions have enableBiDi() (sets webSocketUrl); the project's own test registers an auth handler and navigates with BrowsingContext.navigate(url, COMPLETE), against a page that asks for basic authentication, with no browser excluded.
Read on 14 November 2026: the challenge is taken from WWW-Authenticate for status 401 and from Proxy-Authenticate for status 407, so an authRequired event can also cover a proxy login.
Read on 14 November 2026: Chrome does not use credentials embedded in proxy settings; HTTP proxies use the ordinary sign-in flow (Basic, Digest, Negotiate, NTLM); no authentication method is supported for SOCKS5.
Read on 14 November 2026: a proxy set in the browser options is passed on to Selenium Manager and is used both by the browser and for downloading drivers and browsers; SE_PROXY sets a different proxy for Selenium Manager only.
Proxy302 Python run of the same flow, 18 October 2026
Local example · Confirmed on:
The Selenium use-case page of this site records a Python run of 18 October 2026 (Selenium 4.41.0 and 4.51.0, ChromeDriver 153) through a local password-protected proxy: with BiDi on and the proxy as a --proxy-server flag, the BiDi auth handler loaded an HTTP and an HTTPS page. The Java code on this page has not been compiled or run.
Python, not Java; a different language binding.
Proxy302 product facts and price list
Product observation · Confirmed on:
Product facts file of the site (values checked on 10 November 2026): protocols and ports, prices in US$ (1 PTC = US$1), lease terms, quantity limits, 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.