selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🐛 Bug]: Unable to find a free port starting selenium server 4.5.2 on linux

Open vicozohili opened this issue 4 years ago • 21 comments

What happened?

Caused by: java.lang.RuntimeException: Unable to find a free port at org.openqa.selenium.net.PortProber.findFreePort(PortProber.java:64) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:433) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:128) at org.openqa.selenium.chrome.ChromeDriverInfo.isAvailable(ChromeDriverInfo.java:67) at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174) at java.util.Iterator.forEachRemaining(Iterator.java:116) at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) at org.openqa.selenium.grid.node.config.NodeOptions.discoverDrivers(NodeOptions.java:509) at org.openqa.selenium.grid.node.config.NodeOptions.getSessionFactories(NodeOptions.java:205) at org.openqa.selenium.grid.node.local.LocalNodeFactory.create(LocalNodeFactory.java:80) ... 22 more

How can we reproduce the issue?

Launch selenium server on linux

Relevant log output

.

Operating System

Linux

Selenium version

4.5.2

What are the browser(s) and version(s) where you see this issue?

Chrome

What are the browser driver(s) and version(s) where you see this issue?

chromedriver v106

Are you using Selenium Grid?

4.5.2

vicozohili avatar Oct 22 '22 11:10 vicozohili

@vicozohili, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] avatar Oct 22 '22 11:10 github-actions[bot]

This happened to me also, running a non-grid chrome driver on circleCI, Linux

this is the stack trace:

Caused by: java.lang.RuntimeException: Unable to find a free port at org.openqa.selenium.net.PortProber.findFreePort(PortProber.java:64) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:433) at org.openqa.selenium.chrome.ChromeDriverService.createServiceWithConfig(ChromeDriverService.java:142) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:70)

might be related to: https://github.com/SeleniumHQ/selenium/commit/2eb3a0e4e9724297f362f2bb7b76155a10ab7444

or: https://github.com/SeleniumHQ/selenium/commit/baedf6b16b6a0a0b410a7056c853a5fa1fbe006c

@pujagani @diemol

nir-tal-talkspace avatar Oct 23 '22 05:10 nir-tal-talkspace

Have the same problem since friday

wsieb avatar Oct 24 '22 07:10 wsieb

Same issue on v4.5.1 and v4.5.2. All works fine on v4.5.0. Using on Linux (Ubuntu). Potentially related to this change: https://github.com/SeleniumHQ/selenium/pull/11085/files#diff-8b05a1bfd55e4e3b96646952fb16845057f9b8abeab5c2bd986ca7fa2010cd1bR108

bykes avatar Oct 24 '22 08:10 bykes

Are you all having the issue only on Linux? Are you running the Grid in a containerized environment?

diemol avatar Oct 24 '22 08:10 diemol

only on Linux (Ubuntu) -> Docker Container. Locally on the windows machine the test are running fine

wsieb avatar Oct 24 '22 08:10 wsieb

@diemol my automation runs on Linux (Ubuntu) -> Docker Container on CircleCI. on Mac, i have no issues.

nir-tal-talkspace avatar Oct 24 '22 08:10 nir-tal-talkspace

OK, let me revert that change and avoid checks for Linux .

diemol avatar Oct 24 '22 08:10 diemol

I encountered the same issue when running in Travis CI with docker service. At first I upgraded to 4.5.0 and everything was working okay then since about Friday I started seeing the Unable to find a free port exception. I then tried both 4.3.0 and 4.5.2 but saw the same issue.

I was able to work around this issue by adding the environment variable SE_DOCKER as true to my CI and running with version 4.5.2 which is expecting that env var in this commit. After that everything started working as before.

IdosApplitools avatar Oct 24 '22 09:10 IdosApplitools

I am reverting this change and avoiding the check for Linux, also the SE_DOCKER env var will be removed.

diemol avatar Oct 24 '22 09:10 diemol

I will do a 4.5.3 release in the afternoon.

diemol avatar Oct 24 '22 09:10 diemol

Seeing the same on 4.5.2, Mac Big Sur using WebDriver: org.openqa.selenium.net.PortProber#checkPortIsFree() - isFree("::1", port) returns false

nbrowning1 avatar Oct 24 '22 11:10 nbrowning1

I updated to 4.5.3, still the same problem in ci / docker, any idea how to fix it? thx!

wsieb avatar Oct 24 '22 14:10 wsieb

I did not get any errors in the Docker CI pipeline, which error are you getting? How are you starting the Grid?

diemol avatar Oct 24 '22 14:10 diemol

I use the bonigarcia/webdrivermanager to setup and start the driver in combination with selenide framework

Here is the exception:

Unable to find a free port

java.lang.RuntimeException: Unable to find a free port at org.openqa.selenium.net.PortProber.findFreePort(PortProber.java:64) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:433) at org.openqa.selenium.chrome.ChromeDriverService.createServiceWithConfig(ChromeDriverService.java:142) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:70) at commons.WebDriverUtils.createDriver(WebDriverUtils.java:136)

wsieb avatar Oct 24 '22 14:10 wsieb

I did not get any errors in the Docker CI pipeline, which error are you getting? How are you starting the Grid?

I start the grid using the following in a linux environment

java -jar selenium-server-4.5.0.jar hub java -Dwebdriver.chrome.driver=chromedriver -Dwebdriver.chrome.whitelistedIps= -jar selenium-server-4.5.0.jar node

vicozohili avatar Oct 24 '22 14:10 vicozohili

I did not get any errors in the Docker CI pipeline, which error are you getting? How are you starting the Grid?

I start the grid using the following in a linux environment

java -jar selenium-server-4.5.0.jar hub java -Dwebdriver.chrome.driver=chromedriver -Dwebdriver.chrome.whitelistedIps= -jar selenium-server-4.5.0.jar node

Are you getting this with 4.5.3?

diemol avatar Oct 24 '22 14:10 diemol

I use the bonigarcia/webdrivermanager to setup and start the driver in combination with selenide framework

Here is the exception:

Unable to find a free port

java.lang.RuntimeException: Unable to find a free port at org.openqa.selenium.net.PortProber.findFreePort(PortProber.java:64) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:433) at org.openqa.selenium.chrome.ChromeDriverService.createServiceWithConfig(ChromeDriverService.java:142) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:70) at commons.WebDriverUtils.createDriver(WebDriverUtils.java:136)

@wsieb would need to see a clear way to reproduce this, please

diemol avatar Oct 24 '22 14:10 diemol

updated the chrome & chromedriver to the newest version (106), seems to work now, thx for the help and sorry for the confusion

wsieb avatar Oct 24 '22 16:10 wsieb

@diemol issue is now fixed with 4.5.3 and is now able to launch the grid, however, it fails to launch chrome v107. reverting to 4.5.0 which has no issue for now.

vicozohili avatar Oct 25 '22 18:10 vicozohili