Ubuntu – Cannot connect to the Cassandra

cassandraconnection-refusedUbuntu

My Cassandra used to work with no problems.

I was able to connect with no problems but now for some reason it doesn't work anymore.

[default@unknown] connect localhost/9160;
Exception connecting to localhost/9160. Reason: Connection refused.

and

root# ./bin/cassandra-cli -host localhost -port 9160
Exception connecting to localhost/9160. Reason: Connection refused.

I am on Linux Ubuntu Server.

Thanks in advance…

Best Answer

As others have already suggested make sure your cassandra instance is running

ps axu | grep cassandra

If the output tells you that it is running you can check what ports it is listening on:

netstat -tulpn | grep -i listen | grep <pid>

where is the process id of your cassandra instance which you can get from the output of the first command.

You are interested to find the port 9160 in the output of this command. You will know from this what address it is listening on (if for some reason it is no longer a localhost).

If for some reason you can't find 9160 port in the list of the listening sockets then you might want to check your cassandra.yaml config file (search for rpc_port). You will also find there the address where thrift binds to to listen for clients on.