Database Development

Host machine app unable to query guest machine cassandra database


Ubuntu 18.04 Desktop 64Bit
Visual Studio Code + CassandraCSharpDriver

Ubuntu 18.04 Server
Java and Cassandra installed
Single node
Replication 1
Consistency 1
Cassandra service running
keyspace and table created
Data entered into table
Virtual Box network for guest set to Bridge.

The problem

When I run the code on the host machine, I get an error:

user@desktop:~/Desktop/vsc$ dotnet run
Unhandled exception. Cassandra.NoHostAvailableException: All hosts tried for query failed (tried SocketException 'No route to host')
   at Cassandra.Connections.ControlConnection.Connect(Boolean isInitializing)
   at Cassandra.Connections.ControlConnection.InitAsync()
   at Cassandra.Tasks.TaskHelper.WaitToCompleteAsync(Task task, Int32 timeout)
   at Cassandra.Cluster.Cassandra.SessionManagement.IInternalCluster.OnInitializeAsync()
   at Cassandra.ClusterLifecycleManager.InitializeAsync()
   at Cassandra.Cluster.Cassandra.SessionManagement.IInternalCluster.ConnectAsync[TSession](ISessionFactory`1 sessionFactory, String keyspace)
   at Cassandra.Cluster.ConnectAsync(String keyspace)
   at Cassandra.Tasks.TaskHelper.WaitToComplete(Task task, Int32 timeout)
   at Cassandra.Tasks.TaskHelper.WaitToComplete[T](Task`1 task, Int32 timeout)
   at Cassandra.Cluster.Connect(String keyspace)
   at HelloWorld.Program.Main(String[] args) in /home/userone/Desktop/vsc/Program.cs:line 15

However, I can ping to the guest machine from the host machine without any issues:


I can also ping from the guest machine to the host machine without any issues.

What I have tried

On a Windows machine where the machine runs the code and cassandra on the same host without using a VM, the code and the database work fine as the code is able to insert and select from with database without any issues.


How do I configure the VM guest so I can get the code on the host machine to connect to the cassandra database? I am assuming the issue is happening because the VM is not configured properly?

Leave a Reply

Your email address will not be published. Required fields are marked *