0

Can some help me why i'm facing the below issue and how to fix when I'm trying to start my cqlsh (cassandra).

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")})

When I type below command:

sudo service cassandra status
cassandra (pid  1xxxx) is running...

Which indicates my cassandra is running properly. But unable to run cqlsh. But was able to run yesterday without any issues.

Coming to my cassandra.yaml file

my seed, listen_address, and rpc_address all are set to my public ip address 10.x.xx.xxx.

native_transport_port: 9042

I'm using single node cluster.

Community
  • 1
  • 1
bigdata123
  • 453
  • 2
  • 8
  • 24
  • Which version are you using? – Aaron Dec 04 '15 at 00:20
  • I'm using cassandra 2.1 – bigdata123 Dec 04 '15 at 01:11
  • Have you tried running "nodetool status" to make sure that the local node is up and running normally? – bechbd Dec 04 '15 at 04:11
  • I'm getting below o/p when i run nodetool status ~]# nodetool status Datacenter: datacenter1 ======================= Status=Up/Down |/ State=Normal/Leaving/Joining/Moving -- Address Load Tokens Owns Host ID Rack UN 10.x.x.xxx 289.58 KB 256 ? 65e1133a-c5c3-4ca5-b8bb-357ca4fdb92c rack1 – bigdata123 Dec 04 '15 at 05:12

2 Answers2

1

How are you starting cqlsh? If you want it to connect to an address other than 127.0.0.1, you need to specify it. Specifically, you should try the 10.x.xx.xxx address that you set in your yaml.

$ cqlsh 10.x.xx.xxx

Are you specifying anything for listen_interface or rpc_interface? Remember that you can set either the address or the interface, but not both.

To figure for sure out which address Cassandra is listening on, check your system.log file:

$ grep listening /var/log/cassandra/system.log
INFO  [main] 2015-12-03 21:06:27,581 Server.java:182 - Starting listening for CQL clients on /192.168.0.100:9042...

Assuming that everything is configured properly, and you do not have any errors during startup, the address returned is the one you should be providing when you start cqlsh.

Also, are you trying to connect from the same machine? Or are you trying to remotely connect to your single node? Or is your Cassandra node running on a VM on your machine? Double-check your firewall rules, and ensure that traffic on 9042 can get from your client to your node.

Aaron
  • 55,518
  • 11
  • 116
  • 132
  • Yes i have tried that but no luck,Still getting the same issue. Kindly help – bigdata123 Dec 04 '15 at 00:19
  • I have installed cassandra 2.1. I was working properly before but now it's n't – bigdata123 Dec 04 '15 at 01:12
  • Hi finally i'm able to fix this issue. Ran netstat -tuplen command and found the address to be ---> ::ffff:10.x.x.xxx:9042 .So ran cqlsh ::ffff:10.x.x.xxx:9042 and it started working.... :) – bigdata123 Dec 04 '15 at 08:48
1

I got below output when i ran $ grep listening /var/log/cassandra/system.log

INFO  [main] 2015-12-02 12:49:20,334 Server.java:182 - Starting listening for CQL clients on localhost/127.0.0.1:9042...
INFO  [StorageServiceShutdownHook] 2015-12-02 15:59:11,730 ThriftServer.java:142 - Stop listening to thrift clients
INFO  [StorageServiceShutdownHook] 2015-12-02 15:59:11,771 Server.java:213 - Stop listening for CQL clients
INFO  [main] 2015-12-02 17:21:28,775 Server.java:182 - Starting listening for CQL clients on /10.x.x.xxx:9042...
INFO  [StorageServiceShutdownHook] 2015-12-03 17:12:12,840 ThriftServer.java:142 - Stop listening to thrift clients
INFO  [StorageServiceShutdownHook] 2015-12-03 17:12:12,882 Server.java:213 - Stop listening for CQL clients
INFO  [main] 2015-12-03 17:12:41,337 Server.java:182 - Starting listening for CQL clients on /10.x.x.xxx:9042...
INFO  [StorageServiceShutdownHook] 2015-12-03 17:33:35,996 ThriftServer.java:142 - Stop listening to thrift clients
INFO  [StorageServiceShutdownHook] 2015-12-03 17:33:36,100 Server.java:213 - Stop listening for CQL clients
INFO  [main] 2015-12-03 17:34:00,741 Server.java:182 - Starting listening for CQL clients on /10.x.x.xxx:9042...

Also i'm trying to connect remotely through VPN. I'm using openstack.How to check for firewall issues?

Edit:

Finally I'm able to fix this issue. Ran netstat -tuplen command and found the address to be ::ffff:10.x.x.xxx:9042.

So ran cqlsh ::ffff:10.x.x.xxx:9042 and it started working.

Aaron
  • 55,518
  • 11
  • 116
  • 132
bigdata123
  • 453
  • 2
  • 8
  • 24