Unable to Connect to any Servers Error on Cassandra Seed Host - cassandra

In my Cassandra 3-node setup, all the seed nodes are working fine. However, I am unable to connect to the seed host.
I get 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")})
Please help.

NOTE: As you haven't specified which version of Cassandra you are running, or how you are attempting to connect to your cluster (cqlsh, Java client driver, etc...) I am going to make some assumptions here. For the future, that's good information to provide.
My guess is that if you were to run a nodetool status from one of your nodes, that you wouldn't see "127.0.0.1" in the list. Example:
$ nodetool status | grep 192.168 | awk '{ print $2 }'
192.168.1.1
192.168.1.2
192.168.1.3
My point, is that even if I am on 192.168.1.1, cqlsh 127.0.0.1 or cqlsh (without the IP) won't work. I need to specify the (non-localhost) IP address, which is probably going to be the value of your listen_address or rpc_address.

Related

CQLSH is not executing and Connection Refused

I am unable to execute cqlsh command. I am new to cassandra. I have followed the previous threads. Still unable to execute cqlsh command. Please help me to figure out the issue. Here is the error when I run CQLSH,
[root#Kar 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")})
Thanks,
Karthick
What are the values of your listen_address and broadcast_address?
$ grep _address conf/cassandra.yaml | grep -v "\#"
listen_address: 169.254.93.1
rpc_address: 169.254.93.1
In my case, 169.254.93.1 is the only address that Cassandra will bind on port 9042. Therefore, just running cqlsh (without specifying the IP) only works if they are mapped to the home IP of 127.0.0.1 or localhost.
Therefore, I will need to specify 169.254.93.1 to connect.
$ bin/cqlsh 169.254.93.1 -u flynn -p reindeerFlotilla
Connected to TheGrid at 169.254.93.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
flynn#cqlsh>

Not able to login to cqlsh in Cassandra cluster of 3 nodes hosted in Google cloud platform

I'm setting up a 3 node Cassandra cluster and after installing
cassandra I tried to connect to cassandra using 'cqlsh'
I'm not able to connect to cassandra db terminal.
rammady#deb-cassandra-ram-1:~$ cqlsh 10.142.0.76 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")})
I've modified cassandra.yaml file and provided 1: private ip address
under seed -seed:10.142.0.75,10.142.0.76,10.142.0.77 2:
listen_address: 10.142.0.75 3: rpc_address: 10.142.0.75
You need to connect to the ip you defined in the config:
cqlsh 10.142.0.75
netstat -tulpn would show you, that the node is listening not on the loopback if.

CQLSH is not recognized in google cloud datastax cluster nodes

I have deployed a 4 node datastax cluster in GCP. I can ssh into each of the VM nodes but cqlsh is not recognized.Can you please help me to understand where I am going wrong
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")})
If your cluster is working correctly, then the nodes must know about each other by their own IPs (internal or external). So Cassandra isn't configured to bind 9042 to 127.0.0.1, which means trying to cqlsh to 127.0.0.1:9042 won't work.
One way to check, would be just to do a nodetool status, and use one of those IP addresses. But, as you're on GCP, you may have both internal and external IP addresses, so in that case it really depends on which IP is set as your broadcast_rpc_address. You can check them all by grepping your cassandra.yaml.
$ grep "_address:" cassandra.yaml
listen_address: 192.168.1.3
broadcast_address: 10.20.15.1
# listen_on_broadcast_address: false
rpc_address: 192.168.1.3
broadcast_rpc_address: 10.20.15.1
In this case, your cqlsh command would look something like this:
cqlsh 10.20.15.1 -u youruser -p yourpassword

Cassandra Cqlsh is not working

I've just started working with Cassandra (homebrew install), version 3.7 and cqlsh version 5.0.1. , OS X El Capitan
Cassandra starts up fine and the cluster is operational instantly.
Cqlsh is not working (on any of the nodes) and emits the following error:
Connection error: ('Unable to connect to any servers', {'127.0.0.1':
error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error:
Connection refused")})
Edit cqlsh and change DEFAULT_HOST = IP and then run cqlsh.
I think the first step you should be doing is running netstat -ntpl. This should list down all the ports active on the system. Check for Local Address there you shall find a IP prepended with 9042.
Use this IP to connect ie cqlsh IP . If you do not find the 9042 port in the netstat output than check your cassandra.yaml file. Grep for native_transport_port see if it is 9042 or something different.
If different than connect on that port via cqlsh.
For future reference, if someone else gets it.
I'm running [cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4].
Add start_native_transport: true field in cassandra.yaml file, by default it doesn't enables it and so no rpc communication with client.
Now try connecting with cqlsh rpc_endpoint(rpc addr set in cassandra.yaml).

cqlsh Connection refused

When ever you get a Cassandra cqlsh Connection error as follows:
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")})
You can also connect without using the IP address - just use the hostname:
cqlsh ‘hostname -I’
Another solution, type cqlsh <listen_address> [<port>] if it is not set to 127.0.0.1 or localhost
I was having the same issue with Cassandra 3.11.0, anytime I changed the address of rpc or listen address cqlsh wouldn't work. I had to add the same local ip to seeds
So after trial and error my cassandra.yml looked like:
class-name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
-seeds: "192.168.0.30"
listen_adress: 192.168.0.30
rpc_address: 192.168.0.30
then running
cqlsh 192.168.0.30 9042
When I installed Cassandra 3.11.1, I came across this problem.
I also found if I ran
service cassandra status
, there is a
cassandra dead but pid file exists
problem. It indicates that the Cassandra service does not start
I checked the
/var/log/cassandra/cassandra.log
and found this error:
Exception encountered during startup...
.It is a bug and already reported. The original post link https://issues.apache.org/jira/browse/CASSANDRA-14173.
The solution is to downgrade Cassandra to 3.0
download Cassandra rpm
curl -O
https://www.apache.org/dist/cassandra/redhat/30x/cassandra-3.0.15-1.noarch.rpm
or
wget
https://www.apache.org/dist/cassandra/redhat/30x/cassandra-3.0.15-1.noarch.rpm
rpm -ivh cassandra-3.0.15-1.noarch.rpm
service cassandra start
service cassandra status # check cassandra status, it should say
cassandra (pid 1234) is running...
cqlsh #start cassandra
Hope this helps you

Resources