luke
luke

Reputation: 3599

Selenium - Unable to find a free port

I'm running an app that depends on selenium on FreeBSD server. During the startup I've got the exception:

Caused by: java.lang.RuntimeException: Unable to find a free port
        at org.openqa.selenium.net.PortProber.findFreePort(PortProber.java:67) ~[selenium-remote-driver-2.53.1.jar:na]

I've found some solutions on the internet that the entries which contains 'localhost' should be removed from the hosts file, but I don't have a permission to do that.

Do you know how to fix the problem without modifying /etc/hosts file?

Upvotes: 0

Views: 8061

Answers (5)

Jeena
Jeena

Reputation: 1

ps -ax | grep chrome - find all active chrome. Driver instance

kill 5597 10757 10758 10761 10773 10915 - kill the process ids

Uncomment /etc/hosts file localhost and broadcasthost like below,

127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost

Upvotes: 0

elaveni
elaveni

Reputation: 1

I found free port not an exception in run time, so I went to windows>> preferences>>jre installed >> add >> standard VM >> directory>> the software saved folder is empty, now how I can find the path

Upvotes: 0

Ankush kumar
Ankush kumar

Reputation: 61

Just in case if you are running your scripts on remote server. Then make sure about few points:

  1. Always close or quit your browser after every test run.
  2. Just in case if point one doesn't work then increase the PORT RANGE on your remote server.

Upvotes: 0

Bhuvanesh Mani
Bhuvanesh Mani

Reputation: 1464

Check your JAVA_HOME pointing to some shared drive. If you run your Selenium test from Eclipse IDE, check in Eclipse > Window > Preference > Java > Installed JRE. The active (tick mark selected) should point to local drive's JRE path (Check the column 'Location'). If not, then add local JRE from C:\Program Files\Java\JDK path. Restart your IDE and run now. BINGO!

Upvotes: 1

Juvenik
Juvenik

Reputation: 950

This worked for me without changing the localhost

First get the process id name by greping port no 1024

ps -aux | grep 1024

And then kill that process

kill -9 PROCESS_ID

Upvotes: 0

Related Questions