DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

stephaniesalvador1_162030 avatar image
stephaniesalvador1_162030 asked ·

Why can't I connect with cqlsh to one of the nodes in the DS201 VM for exercise 14?

I'm, working on DS201 Exercise 14 Hinted Handoff. When I start all 3 nodes and go into cqlsh I do get the cql prompt. Per exercise 14, I stop 2 of the nodes then I try to go into cqlsh and I get an error message (see below). How do I fix this? Thank you.
Endpoints:
ubuntu@ds201-node1:~$ /home/ubuntu/node1/resources/cassandra/bin/nodetool getendpoints killrvideo videos_by_tag 'cassandra'
127.0.0.3
127.0.0.2
Then I stop nodes 2 and 3.
Error message:
ubuntu@ds201-node1:~$ /home/ubuntu/node1/resources/cassandra/bin/cqlsh
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")})
academyds201cqlsh
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

The issue is that you're trying to connect to the default CQL port 9042 but node1 is not configured to listen for CQL clients on that port.

I've explained this issue previously in question #4184. I'll post the answer here again.

CQL configuration

cqlsh connects to the default CQL port 9042 but the nodes are configured to listen on different ports in cassandra.yaml:

node1 - native_transport_port: 9041
node2 - native_transport_port: 9042
node3 - native_transport_port: 9043

In my VM instance, netstat shows that the DSE instances are all listening on localhost (127.0.0.1) but on different ports:

$ netstat -tnlp | grep 904
tcp        0      0 127.0.0.1:9041          0.0.0.0:*               LISTEN      1571/java       
tcp        0      0 127.0.0.1:9042          0.0.0.0:*               LISTEN      2139/java       
tcp        0      0 127.0.0.1:9043          0.0.0.0:*               LISTEN      3015/java

This means that if you want to connect to node1 with cqlsh, you need to specify both the IP address and CQL port:

$ cqlsh 127.0.0.1 9041

For more info, see the cqlsh startup options page. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.