Sometimes when I try cqlsh
command on my Ubuntu 22.04 machine I get the following error:
Connection error: (Unable to connect to any servers, {127.0.0.1:9042: ConnectionRefusedError(111, Tried connecting to [(127.0.0.1, 9042)]. Last error: Connection refused)})
And stopping or restarting Cassandra service won't help at all. This happens with no obvious reason, I mean I may exit the cqlsh
and put my laptop on stand-by and comeback after hours and it works, but sometime it won't work!
After trying different solutions on the internet I found that if I run cassandra
command it seems it executes some codes and keeps waiting at the end, but cqlsh
command works after this in a new terminal, even if I cancel or close the previous terminal that I have been running cassandra
command on.
I like to know why this happens after a while and how can I prevent it to happen again? Also what does cassandra
command do? Why systemctl status cassandra
shows it is active with no errors but cqlsh
doesn't work until I run cassandra
command?