Selenium: Invalid "already running" error when starting server - selenium

I am trying to get the Selenium server up and running. However, when I type:
java -jar selenium-server-standalone-2.0b3.jar
I get an Exception:
Selenium is already running on port 4444. Or some other service is.
I have tried to stop it, just in case it really is running:
http://localhost:4444/selenium-server/driver/?cmd=shutDown
That gets me the message:
ERROR Server Exception: sessionId should not be null; has this session been started yet?
If I just write:
http://localhost:4444/
I get:
HTTP ERROR: 403
Forbidden for Proxy
Ideas?

This worked for me:
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
If selenium server is already running on port 4444 then it will shut down the server and says
OKOK
if selenium is not running on this port 4444 then by hitting above url will give you
"Unable to connect"

try this:
lsof -i -n -P | grep 4444
and kill the process it says is on :4444

One-liner:
kill -9 $(lsof -ti tcp:4444)

The error message Selenium offers up is a little confusing. It really should be telling you you're making a syntax error. I had this problem as well. Make sure the cmd string is PRECISELY like this:
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
That means using the full command shutDownSeleniumServer, and make sure the s in shut is lower-case (That was my mistake).
Hope this helps.

To shut down the server you can use:
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
It will give message OKOK , means it got shutdown. If the server is not running then it will show "This web page not available"
To check the selenium server status , use this
http://localhost:4444/selenium-server/driver/?cmd=getLogMessages
It will give OK if server is running , if not running then it will show webpage not available

If you are using Windows, you can open the task manager and locate the java.exe or javaw.exe process and kill it. This will release port 4444 and you should be able to restart the Selenium server.

I had the same error but no server was running.
Tuned out the java version was in cause. Make sure you are running java 7 or higher:
java -version

lsof returned no results in my case.
On a Ubuntu machine I had to do the following:
sudo netstat -tapen | grep ":4444 "
Reply was like:
tcp6 0 0 XXXXXXXXX:4444 :::* LISTEN 107 31526 **10479**/java
And to kill the Selenium server process identified (in my case) with 10479
sudo kill 10479

In OSX if you follow the command from #HaloWebMaster (lsof -i -n -P | grep 4444) the next step is to take the PID (usually a 4 - 5 digit number indicating the process ID) and run the following command:
kill -9 <PID>
You shouldn't need sudo unless the process was started by another user or root.

If you started Selenium using Java (instead of via whatever testing framework you may or may not be using), you can kill all leftover Selenium instances with:
pkill java
That's guaranteed to kill any java relics (including selenium if started this way) - but be careful here - caveat is that you might be killing other procs too (due to the way pkill works). In my case, I want to kill anything running in the JVM, so this solved it for me.
As per the comment from Goldberg below, note that this will not kill any driver services or browsers running on your system!

I had the same problem , I started my Jboss AP where i have my application deployed and after that tried to run the selenium server and couldn t start. The problem was that Jboss uses the same port that Selenium server uses, so what I did is to start selenium server on a different port
Solution:
java -jar selenium-server-standalone-2.0b3.jar -port 1234 -htmlSuite "*firefox" "http://localhost:8080/" "path to the suite" "path to the results"

For Windows, try this:
taskkill /PID <ProcessID> /F

If you get a 403 error on 127.0.01:4444 and not a 404 one, something is running there. (You're positive it cannot be a previous instance Selenium ? It'd be the most logical.)
Sometimes Selenium continue running in the background after an unexpected exit. I'd suggest checking the running processes, or rebooting the machine if everything else fails.
It happens to me frequently when Hudson asks Selenium-Server to run some tests and it fails in the middle for some reasons. Killing the process solves the problem.

That ERROR Server Exception: sessionId should not be null; has this session been started yet? message comes from Selenium. If you're seeing it, there's a Selenium server running on that port number.

If all the above is not working, please save your work and reboot your system. It will solve the problem

Thanks,
The link of Andre works fine for me.
As 4444 is the default port of Selenium check this as well.

Related

bind() failed: Cannot assign requested address (99) error while executing Selenium based automation test in server

I have code for web ui automation test created with Katalon, I have tried to run it locally and it worked well.
Then I push my code to server but when I run it from server, it failed. It failed to open the web/url that i want.
I generate the code to execute test from server but when I run that code this is happened :
bind failed
then it kept loading the browser until it timed out :
Can anyone suggest/comment or help with a solution for this?
This error message...
[SEVERE]: bind() failed: Cannot assign requested address (99)
...implies that the ChromeDriver was unable to bind the Browsing Context i.e. Chrome Browser session.
Initiating ChromeDriver with --verbose flag would have helped to debug the issue in a better way.
Solution
As per the documentation in [Errno 99] Cannot assign requested address when starting Dockerized web app the probhable cause and the solution would be to:
Close all processes that may be running on your port number. Assuming you are running on port 8000:
lsof -t -i tcp:8000 | xargs kill -9
You are probably using an app adress as localhost or 127.0.0.1 and you need to change it to 0.0.0.0
Another possible reason can be, google-chrome attempted to listen on IPv6 address, which was not enabled. You can either enable IPv6 support (which works only on Linux host) or ignore the error since ChromeDriver process will be listening on IPv4 after initial failed attempts.

Cannot start tomcat on port 8080

I have downloaded NetBeans-8.0.1-windows and MySQL 5.0 setup and tomcat 8.5 and successfully installed on win 7 OS.
Now I am trying to start Apache Tomcat but it always shows error like
Starting of Tomcat failed, the server port 8080 is already in use.
Please help to solve this issue. I have downloaded mysql-connector-java-8.0.17.zip and unzipped it.
First, try to check if the port 8080 is on use:
Run command-line as an Administrator. Then run the below mention command.
netstat -ano | findstr :8080
The red-colored circled area shows the PID (process identifier). If you are getting something like the above image, kill the running processes on that port.
Then you execute this command after identifying the PID.
taskkill /PID <typeyourPIDhere> /F
P.S. Run the first command again to check if the process is still available or not. You'll get an empty line if the process is successfully ended.
The answer is taken from the following link: http://www.callstack.in/tech/blog/windows-kill-process-by-port-number-157

Xammp port issue

When i start any web project in netbeans it start tomcat in xammp by dfault but when tomcat is in running state Mysql(php admin) page not open i think there is some kind of port issue please guide me about this issue
change pot mo in config files
Find out what ever the port that error cause and you can kill that usage by following theses steps. Here I take 3325 as my port.
Open cmd and type netstat -ano | findstr 3325.
Then type this code with what ever the output that you gets. Here I get 10360 as my output for the 1st one. taskkill /F /pid 10360
Using this method you can kill the process of port that already in use. Kill the relevant process that is not needed if there are multiple processes hang on this port. This might be helpful to fix your issue.

How may I see that JVM is listening on the port

In preparation for remote debugging I have started (on Mac):
java Test -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9000
It is running in a loop.
Is there a simple way to verify that the process is indeed listening on port 9000?
Will a console command work for you?
netstat -aln | grep 9000
UPD: Who is listening on a given TCP port on Mac OS X?
Looks like the problem was trivial: "java Test -Xdebug... " instead of "java -XDebug ... Test". Wrong order in the command line. Now I see that the JVM listens!

fabric appears to start apache2 but doesn't

I'm using fabric to remotely start a micro aws server, install git and a git repository, adjust apache config and then restart the server.
If at any point, from the fabfile I issue either
sudo('service apache2 restart') or run('sudo service apache2 restart') or a stop and then a start, the command apparently runs, I get the response indicating apache has started, for example
[ec2-184-73-1-113.compute-1.amazonaws.com] sudo: service apache2 start
[ec2-184-73-1-113.compute-1.amazonaws.com] out: * Starting web server apache2
[ec2-184-73-1-113.compute-1.amazonaws.com] out: ...done.
[ec2-184-73-1-113.compute-1.amazonaws.com] out:
However, if I try to connect, the connection is refused and if I ssh into the server and run
sudo service apache2 status it says that "Apache is NOT running"
Whilst sshed in, if run
sudo service apache start, the server is started and I can connect. Has anyone else experienced this? Or does anyone have any tips as to where I could look, in log files etc to work out what has happened. There is nothing in apache2/error.log, syslog or auth.log.
It's not that big a deal, I can work round it. I just don't like such silent failures.
Which version of fabric are you running?
Have you tried to change the pty argument (try to change shell too, but it should not influence things)?
http://docs.fabfile.org/en/1.0.1/api/core/operations.html#fabric.operations.run
You can set the pty argument like this:
sudo('service apache2 restart', pty=False)
Try this:
sudo('service apache2 restart',pty=False)
This worked for me after running into the same problem. I'm not sure why this happens.
This is an instance of this issue and there is an entry in the FAQ that has the pty answer. Unfortunately on CentOS 6 doesn't support pty-less sudo commands and I didn't like the nohup solution since it killed output.
The final entry in the issue mentions using sudo('set -m; service servicename start'). This turns on Job Control and therefore background processes are put in their own process group. As a result they are not terminated when the command ends.
When connecting to your remotes on behalf of a user granted enough privileges (such as root), you can manage system services as shown below:
from fabtools import service
service.restart('apache2')
https://fabtools.readthedocs.org/en/0.13.0/api/service.html
P.S. Its requires the installation of fabtools
pip install fabtools
Couple of more ways to fix the problem.
You could run the fab target with --no-pty option
fab --no-pty <task>
Inside fabfile, set the global environment variable always_use_pty to False, before your target code executes
env.always_use_pty = False
using pty=False still didn't solve it for me. The solution that ended up working for me is doing a double-nohup, like so:
run.sh
#! /usr/bin/env bash
nohup java -jar myapp.jar 2>&1 &
fabfile.py
...
sudo("nohup ./run.sh &> nohup.out", user=env.user, warn_only=True)
...