Cassandra Says Listening on Port 9042 But Couldn't Connect It - cassandra

I've running cassandra on my local machine.
I've starting it sudo service cassandra start. And then check logs under var/log/cassandra/system-log and it says:
INFO [main] 2019-07-28 13:13:17,226 Server.java:162 - Starting listening for CQL clients on localhost/127.0.0.1:9042 (unencrypted)...
INFO [main] 2019-07-28 13:13:17,270 CassandraDaemon.java:501 - Not starting RPC server as requested. Use JMX (StorageService->startRPCServer()) or nodetool (enablethrift) to start it
INFO [SharedPool-Worker-1] 2019-07-28 13:13:27,133 ApproximateTime.java:44 - Scheduling approximate time-check task with a precision of 10 milliseconds
INFO [OptionalTasks:1] 2019-07-28 13:13:27,298 CassandraRoleManager.java:339 - Created default superuser role 'cassandra'
Then I try to connect with cqlsh in terminal and it says:
Connection error: ('Unable to connect to any servers', {'127.0.0.1:9042': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
What is wrong? Also I couldn't see 9042 port with netstat -tulpn command.

Go to /etc/cassandra/cassandra-env.sh
Uncomment
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"
and change it to
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname==localhost"
Set listen_address and broadcast_rpc_address to local ip (get ip address from ifconfig).
Restart Cassandra.

cqlsh localhost 9042
This would work if you didn't change the cassandra.yml file.

Related

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

Cant' connect to Cassandra with cqlsh

When i tried to connect to my cassandra cluster with cqlsh, i had this 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")})
So i go to the cassandra.yaml file but my rpc_adress and listen_address parameters are goods.
There is my listen_adress :
# ipv4. If there is only one address it will be selected regardless of ipv4/ipv6.
listen_address: localhost
# listen_interface: eth0
# listen_interface_prefer_ipv6: false
And my rpc_address :
rpc_address: localhost
# port for Thrift to listen for clients on
rpc_port: 9160
I also tried to modify the file, but i dont have the right for it.
Thank you in advance

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

facing connection error when trying to open cqlsh prompt

Can some help me why i'm facing the below issue and how to fix when I'm trying to start my cqlsh (cassandra).
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")})
When I type below command:
sudo service cassandra status
cassandra (pid 1xxxx) is running...
Which indicates my cassandra is running properly.
But unable to run cqlsh. But was able to run yesterday without any issues.
Coming to my cassandra.yaml file
my seed, listen_address, and rpc_address all are set to my public ip address 10.x.xx.xxx.
native_transport_port: 9042
I'm using single node cluster.
How are you starting cqlsh? If you want it to connect to an address other than 127.0.0.1, you need to specify it. Specifically, you should try the 10.x.xx.xxx address that you set in your yaml.
$ cqlsh 10.x.xx.xxx
Are you specifying anything for listen_interface or rpc_interface? Remember that you can set either the address or the interface, but not both.
To figure for sure out which address Cassandra is listening on, check your system.log file:
$ grep listening /var/log/cassandra/system.log
INFO [main] 2015-12-03 21:06:27,581 Server.java:182 - Starting listening for CQL clients on /192.168.0.100:9042...
Assuming that everything is configured properly, and you do not have any errors during startup, the address returned is the one you should be providing when you start cqlsh.
Also, are you trying to connect from the same machine? Or are you trying to remotely connect to your single node? Or is your Cassandra node running on a VM on your machine? Double-check your firewall rules, and ensure that traffic on 9042 can get from your client to your node.
I got below output when i ran $ grep listening /var/log/cassandra/system.log
INFO [main] 2015-12-02 12:49:20,334 Server.java:182 - Starting listening for CQL clients on localhost/127.0.0.1:9042...
INFO [StorageServiceShutdownHook] 2015-12-02 15:59:11,730 ThriftServer.java:142 - Stop listening to thrift clients
INFO [StorageServiceShutdownHook] 2015-12-02 15:59:11,771 Server.java:213 - Stop listening for CQL clients
INFO [main] 2015-12-02 17:21:28,775 Server.java:182 - Starting listening for CQL clients on /10.x.x.xxx:9042...
INFO [StorageServiceShutdownHook] 2015-12-03 17:12:12,840 ThriftServer.java:142 - Stop listening to thrift clients
INFO [StorageServiceShutdownHook] 2015-12-03 17:12:12,882 Server.java:213 - Stop listening for CQL clients
INFO [main] 2015-12-03 17:12:41,337 Server.java:182 - Starting listening for CQL clients on /10.x.x.xxx:9042...
INFO [StorageServiceShutdownHook] 2015-12-03 17:33:35,996 ThriftServer.java:142 - Stop listening to thrift clients
INFO [StorageServiceShutdownHook] 2015-12-03 17:33:36,100 Server.java:213 - Stop listening for CQL clients
INFO [main] 2015-12-03 17:34:00,741 Server.java:182 - Starting listening for CQL clients on /10.x.x.xxx:9042...
Also i'm trying to connect remotely through VPN. I'm using openstack.How to check for firewall issues?
Edit:
Finally I'm able to fix this issue. Ran netstat -tuplen command and found the address to be ::ffff:10.x.x.xxx:9042.
So ran cqlsh ::ffff:10.x.x.xxx:9042 and it started working.

Resources