selenium: [πŸ› Bug]: Trying to use socks5 proxy

What happened?

I am encountering an issue while using Selenium with Java to connect to a 4G proxy via SOCKS5 The browser opens successfully but there seems to be no actual internet connection within the browser I have reviewed my code and configurations, but I’m unable to identify the root cause of this problem

How can we reproduce the issue?

public static void main(String[] args) {
        String host = "hostprodiverhere (and yes it's correct )";
        String port = "(a correct port here)";

        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.addArguments("--proxy-server=socks5://" + host + ":" + port);

        WebDriver driver = new ChromeDriver(chromeOptions);

        driver.get("https://whoer.net/");
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
}

Relevant log output

Normal output no errors

Operating System

Linux (Ubuntu)

Selenium version

4.11.0

What are the browser(s) and version(s) where you see this issue?

chrome

What are the browser driver(s) and version(s) where you see this issue?

chromedriver

Are you using Selenium Grid?

no webdriver

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Does that mean you got it working, or not? If not, please submit the logs obtained based on the above documentation.

Looks like it wants you to specify socks version as well

Hopefully, it’s just:

        ChromeOptions options = new ChromeOptions();
        Proxy proxy = new Proxy();
        proxy.setSocksProxy(host + ":" + port);
        options.setProxy(proxy);
        driver = new ChromeDriver(options);

@titusfortner Thank you bro I just subscribed to your youtube channel

Selenium does not manage Chrome arguments, so if --proxy-server is broken, it will need to be reported to Google.

The Selenium supported way of adding a proxy is to use the options.setProxy(myProxy). The Selenium Proxy object allows setting socksProxy value. This may still be an issue that Google needs to solve, but see if it works with this approach.