5

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...

3
  • Have your verified that the cassandra daemon is actually running? Find anything informative in its log files?
    – andol
    Jul 31, 2011 at 14:51
  • Did you check to see if Cassandra is listening on port 9160: lsof -i :9160, netstat -nl | grep 9160, ...?
    – quanta
    Jul 31, 2011 at 14:52
  • possible duplicate of What causes the 'Connection Refused' message?
    – user9517
    Sep 28, 2015 at 18:24

2 Answers 2

6

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.

3
  • i'm using first command 6335 0.0 0.0 14228 968 pts/6 S+ 17:13 0:00 grep --color=auto cassandra
    – Umapathi
    Apr 18, 2018 at 11:45
  • second command netstat -tulpn | grep -i listen | grep 6335 but my issue is not resloved
    – Umapathi
    Apr 18, 2018 at 11:45
  • using cqlsh command Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
    – Umapathi
    Apr 18, 2018 at 11:46
4

By default Thrift is not up, you have to start it with

nodetool enablethrift
2
  • 3
    Can you add detail on how this answers the question or improves on the accepted answer?
    – Dave M
    Jan 11, 2016 at 13:54
  • We can use netstat -atn to check whether port 9160 is active or not. As given by Perry Cox we can execute nodetool enablethrift to enable Thrift communication. It was veryuseful for me to run kairosdb. Feb 18, 2016 at 12:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .