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:


stephaniesalvador1_162030 avatar image
stephaniesalvador1_162030 asked Erick Ramirez commented

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.
ubuntu@ds201-node1:~$ /home/ubuntu/node1/resources/cassandra/bin/nodetool getendpoints killrvideo videos_by_tag 'cassandra'
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', {'': error(111, "Tried connecting to [('', 9042)]. Last error: Connection refused")})
10 |1000

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 Erick Ramirez commented

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 ( but on different ports:

$ netstat -tnlp | grep 904
tcp        0      0*               LISTEN      1571/java       
tcp        0      0*               LISTEN      2139/java       
tcp        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 9041

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

2 comments Share
10 |1000

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

I am very grateful for your answer. Thank you!

0 Likes 0 ·

Happy to help. Cheers!

0 Likes 0 ·