The Linux Page

Cannot connect my Host system to Cassandra running on my Guest VM

I found a different way which is to use the:
Local Network or Host-only Network on your Virtual Machine

Today I did my first full install of Snap on a VM in my Ubuntu development system that runs VirtualBox.

This took me about 1h between getting all the files ready from our own APT repository, and then finding out all the setups needed (we have a few working installations, but we added all the necessary magic with time and did not clearly document all the steps yet... argh! so much to do!)

At some point, I wanted to setup the "domains" and "websites" tables on the VM. To do that I have to run the snapmanager tool. However, that tool requires X-Windows and my VM is just a server, so absolutely no X. Because of that, I have to run the snapmanager from my Host system and connect to my VM. To do that, I simply had to add a Port Forwarding to my VM setup and connect, right?

The port forwarding setup looks like this in the setup window. As you can see, I also setup Apache with port 8888.

Port Forwarding Screenshot

The fact is that was not enough. It worked for Apache, but not for Cassandra. This is because Cassandra is setup to listen to localhost by default and as such it will refuse connections from other computers, including the host.

So, I had to edit the /etc/cassandra/cassandra.yaml file and change the listen host address of the RPC port to 0.0.0.0:

rpc_address: 0.0.0.0

Of course, if you have a local network properly setup, you probably want to use something a little more constrained such as 192.168.0.3.

Before doing so, when I tried the following:

telnet localhost 9161

It would immediately exit with an error saying that the remote host closed the connection immediately. I also tried with thrift which would tell me that the connection was refused.

Note that using telnet on the VM directly, with port 9160, would start a connection and sit there waiting for data. So it was clear that the Cassandra instance was running as expected.