How to fix "[SEVERE]: bind() failed: Cannot assign requested address (99)" while starting chromedriver
LinuxSelenium ChromedriverLinux Problem Overview
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?
Linux Solutions
Solution 1 - Linux
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.
Solution 2 - Linux
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=
Solution 3 - Linux
I managed to workaround by adding argument as shown below (Python)
options = webdriver.ChromeOptions()
options.add_argument('--disable-dev-shm-usage')
Solution 4 - Linux
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.
Solution 5 - Linux
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
Solution 6 - Linux
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.
Solution 7 - Linux
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.