0

I'm new to Cassandra and was trying it out. Despite Cassandra apparently running and listening (according to lsof) I can't connect to it. sudo systemctl status cassandr also reports active (running).

$ sudo lsof -Pnl +M -i4 
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
(omitting unrelated services - nothing here about cassandra)

$ sudo lsof -Pnl +M -i6
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd      752        0    4u  IPv6  16234      0t0  TCP *:22 (LISTEN)
java    23659      300   68u  IPv6 158110      0t0  TCP 127.0.0.1:7199 (LISTEN)
java    23659      300   69u  IPv6 158122      0t0  TCP 127.0.0.1:36921 (LISTEN)
java    23659      300   84u  IPv6 158212      0t0  TCP 127.0.0.1:9160 (LISTEN)
java    23659      300  151u  IPv6 158205      0t0  TCP 127.0.0.1:7000 (LISTEN)



$ sudo nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Owns (effective)  Host ID                               Token                                    Rack
UN  127.0.0.1  125.98 KiB  100.0%            e0bbc831-8686-43a6-b99c-8ea5596c8581  3840369556391221198                      rack1

For Nix users who might be reading this (also easy to grasp for non-Nix users), my config is just:

  services.cassandra = {
    enable = true;
    listenAddress = "127.0.0.1";
    rpcAddress = "127.0.0.1";
  };

The error I get is:

$ cqlsh 127.0.0.1 9160
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9160)]. Last error: Connection refused")})
bbarker
  • 11,636
  • 9
  • 38
  • 62

2 Answers2

1

Try using native_transport_port 9042 rather than rpc_port 9160 while connecting though cqlsh.

cqlsh 127.0.0.1 9042

If you still get this error then check your Cassandra configuration as per link this and this

Laxmikant
  • 1,551
  • 1
  • 13
  • 30
0

I should have checked on the nixpks issue tracker, as I found the answer there; I needed:

extraConfig = {
  start_native_transport = true;
};
bbarker
  • 11,636
  • 9
  • 38
  • 62