Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 764
LisaQiu Avatar asked Apr 25 '19 08:04

LisaQiu


3 Answers

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.

like image 59
Yaroslav Admin Avatar answered Nov 05 '22 03:11

Yaroslav Admin


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=
like image 25
GetoX Avatar answered Nov 05 '22 02:11

GetoX


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

like image 9
Assi.NET Avatar answered Nov 05 '22 02:11

Assi.NET