Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

rahul.samant07_60857 avatar image
rahul.samant07_60857 asked Erick Ramirez edited

Why can't I connect to nodes with cqlsh in the DS210 lab?

getting Below error while starting cql using cqlsh command

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

Servers are up in multiple DC

ubuntu@ds210-node1:/etc/dse/cassandra$ nodetool status
Datacenter: dc1
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving/Stopped
-- Address Load Tokens Owns (effective) Host ID Rack
UN 172.18.0.2 306.33 KiB 8 6.0% 430b7ebd-afc8-400a-8053-32c9929a48e9 rack1
UN 172.18.0.3 379.2 KiB 128 89.1% 116d1b49-7b77-4912-b7bf-077c30f22c2e rack1
Datacenter: dc2
===============
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving/Stopped
-- Address Load Tokens Owns (effective) Host ID Rack
UN 172.18.0.4 243.26 KiB 8 4.8% cc79ee25-9359-48a0-894d-c9eec803477f rack1

nodetool commands are running fine but somehow cqlsh is not working

What could be the issue ?

cqlsh
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 Erick Ramirez edited

It's very rare that the Cassandra nodes are configured to listen for CQL clients on localhost. Typically, this would only happen if you were running up a quick test on a single node.

In your case, you would have configured the nodes to listen for CQL clients using a publicly-addressable IP. In DSE, it's the native_transport_address property in cassandra.yaml (rpc_address in open-source Cassandra).

When you run cqlsh on its own, it connects to localhost (127.0.0.1) by default. The correct format is:

$ cqlsh <ip_address>

For details, see Starting cqlsh. Cheers!

2 comments 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.

Thanks Erick . it worked. apology for silly Query

0 Likes 0 ·

Not silly at all. We're happy to help. Cheers!

0 Likes 0 ·