Unable to find a free port

1,112 views
Skip to first unread message

michael dey

unread,
Feb 6, 2019, 3:11:55 AM2/6/19
to Selenium Users
Hi guys, I am trying to learn Selenium for Java. I am getting the following error when I try to run in Eclipse:

Exception in thread "main" java.lang.RuntimeException: Unable to find a free port

at org.openqa.selenium.net.PortProber.findFreePort(PortProber.java:67)

at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:351)

at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:190)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:147)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)

at basicweb.TestClass.main(TestClass.java:12)


I am on a Mac running macOS Mojave Version 10.14.3

I am running Eclipse Version: 2018-12 (4.10.0) 

My Firefox  is Firefox Quantum 65.(64-bit)

My geckodriver is v0.24.0

java version 11.0.2

Java Runtime Environment 18.9


I am just trying to run even the most basic code.

package basicweb;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestClass

{
 
public static void main(String[] args)
 
{
 
System.setProperty("webdriver.firefox.driver", "/Users/mdey/eclipse-workspace/SeleniumTutorial/Webdrivers/geckodriver");
 
WebDriver driver = new FirefoxDriver();
 driver
.get("http://www.google.com");
 
}



I have tried with and without setting the driver location with setProperty.

I have tried running this code, just with the chrome driver, and I get the same error.

I have tried uninstalling java and re-installing java and JRE, uninstalling and re-installing eclipse, and I have tried several versions and combinations of Java, Firefox, and the webdriver.

  

I am not sure what else to do, and I am really hopeful someone can help me out! Thanks in advance for your support and all you do!

michael dey

unread,
Feb 7, 2019, 1:58:19 PM2/7/19
to Selenium Users
After several tests on different networks, it appears my problem has to do with my network's firewall settings. My geckodriver will work when I am on a different network.

Nam Lê

unread,
Aug 15, 2019, 11:09:04 AM8/15/19
to Selenium Users

65f4437b8c206b7e3231.jpg

bf601893d1c836966fd9.jpg

Check port range PortProber use to Random. 
 

Sumalatha M

unread,
Jan 30, 2022, 4:19:18 AM1/30/22
to Selenium Users

Exception in thread "main" java.lang.RuntimeException: Unable to find a free port

even am getting the same error i should i solve am stuck please help!!
Reply all
Reply to author
Forward
0 new messages