How to fix "[SEVERE]: bind() failed: Cannot assign requested address (99)" while starting chromedriver
Asked Answered
M

9

66

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

Meimeibers answered 25/4, 2019 at 8:19 Comment(1)
H
45

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.

Harvest answered 2/8, 2019 at 14:10 Comment(3)
Hi, how to "ignore the error"? in my case the container stopped, when I did nothing.Bodgie
@Bodgie 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.Harvest
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.Bodgie
P
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=
Psyche answered 7/8, 2020 at 23:52 Comment(1)
What is the reason for that?Monkey
R
13

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

Romantic answered 18/4, 2021 at 22:35 Comment(2)
This may be specific to Docker on Windows, as this just started a couple days ago since upgrading to a new versionFaultfinder
This will fix the issue if your shm size is too small (typically in Docker environments. See developers.google.com/web/tools/puppeteer/…Yousuf
J
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.

Judiciary answered 16/7, 2020 at 21:14 Comment(0)
C
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

Caine answered 3/8, 2021 at 14:27 Comment(0)
P
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.

Projective answered 21/8, 2020 at 23:20 Comment(0)
B
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.

Bernard answered 23/1, 2020 at 17:3 Comment(0)
H
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.

Heresy answered 10/12, 2022 at 21:37 Comment(0)
P
0

finally found the overkill solution after investing 10s of hours. first of all chromeoptions:

ChromeOptions options = new ChromeOptions();
System.setProperty("webdriver.chrome.whitelistedIps", "");
options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--disable-gpu");
options.addArguments("--window-size=1920,1080");
options.addArguments("--remote-debugging-port=9222");
options.addArguments("--disable-extensions");
options.addArguments("--disable-software-rasterizer");

secondly your docker does not have display, add this:

Xvfb :99 -screen 0 1920x1080x24 &
# Give Xvfb some time to start
echo "Xvfb started."
sleep 5

now build!

still not working(java). remember you copied your war file but target is still not updated with options rebuild it

Pomegranate answered 4/7 at 17:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.