3

I have installed the Cassandra and not able to connect using cqlsh:

[cassandra@linuxdr ~]$ which cassandra 
/usr/sbin/cassandra
[cassandra@linuxdr ~]$ cassandra -v
4.0.5
[cassandra@linuxdr ~]$ sudo systemctl status cassandra.service
Active: active (running)

[cassandra@linuxdr ~]$ grep rpc_address /etc/cassandra/conf/cassandra.yaml
rpc_address: 192.168.56.9
[cassandra@linuxdr ~]$ sudo cqlsh 192.168.56.9 9042 -u cassandra -p cassandra 
Connection error: ('Unable to connect to any servers', {'192.168.56.9:9042': 
ConnectionRefusedError(111,  "Tried connecting to [('192.168.56.9', 9042)]. Last error: Connection refused")}) 
[cassandra@linuxdr ~]$ netstat -an | grep 9042 
[cassandra@linuxdr ~]$ telnet 192.168.56.9 9042 
Trying 192.168.56.9... telnet: connect to address 192.168.56.9: Connection refused

How can I connect? Is there anything else I can try?

I am trying the nodetool from the same node

[cassandra@linuxdr ~]$ nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address       Load        Tokens  Owns (effective)  Host ID  Rack 
UN  192.168.56.9  168.15 KiB  16      100.0%                     rack1

[cassandra@linuxdr ~]$ sudo cqlsh 192.168.56.9 9042 -u cassandra -p cassandra
Connection error: ('Unable to connect to any servers', {'192.168.56.9:9042': ConnectionRefusedError(111, "Tried connecting to [('192.168.56.9', 9042)]. Last error: Connection refused")})

[cassandra@linuxdr ~]$ grep _address /etc/cassandra/conf/cassandra.yaml | grep -v '#'
listen_address: 192.168.56.9
rpc_address: 192.168.56.9
3
  • Does nodetool status show the same IP or a different one?
    – Aaron
    Commented Dec 11, 2022 at 23:22
  • Thanks for the help , please see below. [cassandra@linuxdr ~]$ sudo nodetool status nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'.
    – dbabhavani
    Commented Dec 12, 2022 at 2:02
  • Are you running nodetool on the same machine that's running Cassandra? Also, adjust your grep above and try this: grep _address /etc/cassandra/conf/cassandra.yaml | grep -v "#". What other IPs do you see?
    – Aaron
    Commented Dec 12, 2022 at 13:12

1 Answer 1

1

The symptoms you described indicate that the node is not listening for client connections on port 9042. Cassandra is running in a sort of degraded mode so despite showing as "up" and "normal" (UN in nodetool status output), the client native transport (CQL binary protocol) is disabled.

It is simple to verify whether the Cassandra process is listening for client connections on port 9042 using Linux utilities like lsof or netstat:

$ sudo lsof -nPi -sTCP:LISTEN
$ sudo netstat -tnlp

This can happen if someone ran nodetool drain on the node (status will be listed as DRAINED in the nodetool netstats output), or if someone ran nodetool disablebinary.

In the worst case, if the node encountered some form of disk failure then it would have triggered Cassandra to go into maintenance mode where both gossip (port 7000 by default) and native transport are stopped but the process is still running so can be interrogated via JMX (the nodetool utility connects via JMX).

You will need to review the Cassandra logs (default location is /var/log/cassandra), going through the warnings and/or errors for clues as to why you can't connect. Cheers!


👉 Please support the Apache Cassandra community by hovering over the tag then click on the Watch tag button. 🙏 Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.