Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Getting "connection refused" error while logging into Cassandra

When we are trying to login to Cassandra on Private Cloud version 4.16.05, we are getting the following error:

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")})
Solved Solved
0 4 28.1K
1 ACCEPTED SOLUTION

To understand the cause for "Connection refused" error, tried out the following steps:

1. Ran the netstat command and got the following output:

[root@adevegowda bin]# 
netstat -an | grep 9042 tcp 0 0 ::ffff:10.1.22.10:9042 :::* LISTEN 

The above output indicated that we are listening on port 9042 and IP address 10.1.22.10.


2. However, the error clearly showed that cqlsh was trying to connect to 127.0.0.1 by default. So we were getting "connection refused" error.

3. Modified the cqlsh command to connect to the IP address 10.1.22.10 and re-ran it as follows and we were able to connect to Cassandra database successfully.

[root@adevegowda bin]# sudo /opt/apigee/apigee-cassandra/bin/cqlsh 10.1.22.10 9042 -u cassandra -p cassandra 
Connected to Apigee at 10.1.22.10:9042. 
[cqlsh 5.0.1 | Cassandra 2.1.13 | CQL spec 3.2.1 | Native protocol v3] 
Use HELP for help. 
cassandra@cqlsh> 

In Summary, the command is:

sudo /opt/apigee/apigee-cassandra/bin/cqlsh <IP-address> <port#> -u cassandra -p cassandra 

View solution in original post

4 REPLIES 4