How do I connect to a Cassandra VM
.AddContactPoint("127.0.0.1")
If that works from the same machine, then you probably have Cassandra bound to that IP. If you need to connect to your node(s) remotely, then you need to bind a routeable IP to that node.
Run a nodetool status
. If you see your cluster status showing your node with an IP of 127.0.0.1, then connecting to the local machine from the local machine is the only scenario that will ever work.
Try running the following command on your node:
grep _address cassandra.yaml
The IP address returned in the output is the only one that an application is allowed to connect to. If you want to be able to connect to 192.168.0.18, then the listen
and rpc
addresses should look something like this:
listen_address: 192.168.0.18
rpc_address: 192.168.0.18
Note that you'll need to change your seeds
list, too.
Also, if you're on a VM/provider that has both internal and external IP addresses, then you'll also need to set your broadcast_
addresses to the external IP:
broadcast_address: 10.6.5.5
broadcast_rpc_address: 10.6.5.5
listen_address: 192.168.0.18
rpc_address: 192.168.0.18
But try setting just listen
and rpc
to 192.168.0.18 first.
Edit 20191022
Just wanted to double check, do I add 192.168.0.18 as the listen_address and rpc_address to the cassandra node where the cassandra node has the ip address 192.168.0.18?
Yes. Also make sure that your node's seed list is set like this:
- seeds: "192.168.0.18"
Before I did that, the value of the listen_address and rpc_address were set to localhost
I thought so.
However, after making the changes you suggested, nodetool status now gives me
Failed to connect to 127.0.0.1:7199 - connection refused
Ironically, that's the same message nodetool returns when Cassandra is not running. At this point I would check the system log and see if it is returning errors that may be preventing it from starting. I suspect that the seed list still reads "127.0.0.1".
tl;dr;
If you intend to connect to your cluster/node remotely, then you cannot use the default configurations which bind Cassandra to the home IP (127.0.0.1/localhost). And that includes all _address
settings, as well as your seeds
list.