64

I downloaded the latest version of chromedriver in Centos 7 platform: https://chromedriver.storage.googleapis.com/index.html?path=74.0.3729.6/ I start chromedriver and get this error.

Error :

Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1556179366.141][SEVERE]: bind() failed: Cannot assign requested address (99)

How can I solve this?

enter image description here

Timo Tijhof
  • 10,032
  • 6
  • 34
  • 48
LisaQiu
  • 649
  • 1
  • 5
  • 4
  • [When running WebDriver with Chrome browser, getting message, “Only local connections are allowed” even though browser launches properly](https://stackoverflow.com/q/25080500/608639), [Only local connections are allowed Chrome and Selenium webdriver](https://stackoverflow.com/q/38846079/608639), [Selenium for ChromeDriver and Chrome Browser and the log message “Only local connections are allowed”](https://stackoverflow.com/q/48547360/608639), etc. – jww Apr 25 '19 at 12:03

8 Answers8

42

In my case running chromedriver with --verbose flag helped to figure out the issue:

[1564749154.010][SEVERE]: bind() failed: Cannot assign requested address (99)
[1564749154.011][INFO]: listen on IPv6 failed with error ERR_ADDRESS_INVALID

Chrome attempted to listen on IPv6 address, which was not enabled in Docker. You can either enable IPv6 support (which works only on Linux host) or ignore the error since chromedriver process will be listening on IPv4 anyway.

Yaroslav Admin
  • 13,880
  • 6
  • 63
  • 83
  • 9
    Hi, how to "ignore the error"? in my case the container stopped, when I did nothing. – sww176 Aug 08 '19 at 15:50
  • @sww176 Maybe it is something else causing the error in your case. Do you get exact same output? In my case the process continues to work after printing the error message. – Yaroslav Admin Aug 08 '19 at 15:52
  • 1
    It's the same error. I added --verbose flag and the chromedriver.log shows [1564749154.011][INFO]: listen on IPv6 failed with error ERR_ADDRESS_INVALID. I fixed this by adding --whitelisted-ips to webdriver args. Thanks for your help. – sww176 Aug 09 '19 at 09:28
27

In one line: you need to pass --whitelisted-ips= into chrome driver (not chrome!)

You can do it in different way (depend on your env setup):

If you use ChromeDriver locally/directly (not using RemoteWebDriver) from code, just insert lines below before ChromeDriver init

    System.setProperty("webdriver.chrome.whitelistedIps", "");

If you use it remotely (eg. selenium hub/grid) you need to set system property when node starts, like in command:

java -Dwebdriver.chrome.whitelistedIps= testClass etc...

or docker by passing JAVA_OPTS env

  chrome:
    image: selenium/node-chrome:3.141.59
    container_name: chrome
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
      - JAVA_OPTS=-Dwebdriver.chrome.whitelistedIps=
GetoX
  • 4,225
  • 2
  • 33
  • 30
12

I managed to workaround by adding argument as shown below (Python)

options = webdriver.ChromeOptions()
options.add_argument('--disable-dev-shm-usage')

This is from Google's troubleshooting tips:

By default, Docker runs a container with a /dev/shm shared memory space 64MB. This is typically too small for Chrome and will cause Chrome to crash when rendering large pages. To fix, run the container with docker run --shm-size=1gb to increase the size of /dev/shm. Since Chrome 65, this is no longer necessary. Instead, launch the browser with the --disable-dev-shm-usage flag

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Assi.NET
  • 432
  • 4
  • 7
  • 4
    This may be specific to Docker on Windows, as this just started a couple days ago since upgrading to a new version – Steve Desmond Apr 22 '21 at 19:08
  • 2
    This will fix the issue if your `shm` size is too small (typically in Docker environments. See https://developers.google.com/web/tools/puppeteer/troubleshooting#running_on_alpine – Gene Jul 27 '21 at 13:43
5

The cause lay somewhere else. I was running chrome on docker container and for me this was solved when the driver was run in a headless mode.

ChromeOptions options = new ChromeOptions().setHeadless(true);
WebDriver driver = new ChromeDriver(options);

Results: Now tests run successfully, without any errors.

Tony Joseph
  • 1,802
  • 2
  • 14
  • 17
Pramod Yadav
  • 467
  • 8
  • 14
3

I had the same issue in my team, but in our case the solution is completely new. Probably because the root cause is different, although the visible error message was the same.

The issue started to occur in our CI/CD pipeline 5 days ago. We realised that at the same time new selenium/standalone-chrome docker image was pushed to selenium docker hub.

https://hub.docker.com/r/selenium/standalone-chrome/tags

That latest image caused this error. It never happened before during 1.5 year period. But it happened with that latest image. Digest of that image: 9943ba9d2a89e984080f5681b390229fb47f7d3bb732e4f440456fc52335bae8

The solution was reverting the image used by our Jenkins to the selenium/standalone-chrome docker image that was pushed 21 days ago. Digest: bc4023992691ab8e2f20297f334fdcddd982928fbd969239b39b3dbc2dfc0657

We are planning to check the new images to come for compatibility with our CI/CD so that we can get back up to date with the latest selenium images

Thanks

justnpT
  • 1,039
  • 9
  • 7
1

I had the similar problem; and my issue was i did not quit the existing driver and tried to use again. driver.quit() solved my problem.

Emre Bayram
  • 139
  • 2
  • 9
0

In my case, there we 2 docker containers running and the port 4444 used by selenium. Closing one container solved the issue for the other one. The message is still there, but the tests are running. Earlier they were getting stuck.

Ravindra
  • 1
  • 2
0

I encountered this when trying to run tests (Java) in a container ubuntu:20.04. Extracted the following from this guidance Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed

ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox", "--headless", "--window-size=1024x768");

There are threads stating --no-sandbox has to be first, but I experimented and this was not necessary, at least in Java.

Jules Clements
  • 418
  • 5
  • 8