When running WebDriver with Chrome browser, getting message, "Only local connections are allowed" even though browser launches properly

When I run Chrome browser using WebDriver, I am getting following message on console. Please let me know how to resolve it.

"Starting ChromeDriver (v2.10.267521) on port 22582 " "Only local connections are allowed."

Here is my sample code:

public class Browserlaunch {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "C:\\chromedriver_win32   \\chromedriver.exe");
        WebDriver driver = new ChromeDriver() ;
        driver.get("http://webdunia.com");
        driver.close();
        driver.quit();
    }
}

Solution 1:

This is an informational message only. What the message is telling you is that the chromedriver executable will only accept connections from the local machine.

Most driver implementations (the Chrome driver and the IE driver for sure) create a HTTP server. The language bindings (Java, Python, Ruby, .NET, etc.) all use a JSON-over-HTTP protocol to communicate with the driver and automate the browser. Since the HTTP server is simply listening on an open port for HTTP requests generated by the language bindings, connections to the HTTP server started by the language bindings are only allowed to come from other processes on the same host. Note carefully that this limitation does not apply to connections the browser can make to outside websites; rather it simply prevents incoming connections from other websites.

Solution 2:

Not necessarily the best practice, but my environment was a local network with several machines which needed access to the selenium.

When running the chromedriver, you can pass through a param like so :

chromedriver --whitelisted-ips=""

This will basically whitelist all IP's, not always an ideal solution of course and be careful with it for production enviornments, but you should be presented with a verbose warning :

Starting ChromeDriver 2.16.333244 (15fb740a49ab3660b8f8d496cfab2e4d37c7e6ca) on port 9515 All remote connections are allowed. Use a whitelist instead!

A work-around at best, but it works.

Relative check-in