'cassandra All hosts tried for query failed CassandraCSharpDriver

I tried to connect cassandra from virtual machine to main machine and use it with CassandraCSharpDriver. The error is "All hosts tried for query failed (tried :: SocketException 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond')". I already have cassandra tested on main machine (x.x.x.1) and it worked, then I create 3 virtual machine with cassandra on it (x.x.x.2),(x.x.x.3),(x.x.x.4) but none of them worked on main machine. I even tried add all of the IP in the .yaml config file but doesn't seem work, althought x2, x3, x4 connected to each others on virtualbox with the same way. Is there anything I need to check in order to connect 3 virtual machine to main machine. Here is what I have done: config virt machine network to host-only; config virt machine IP to static; config .yaml file both virt and main machine; create keyspace, table. Here is the code create ISession

public static DataConnection Ins
{
    get
    {
        if (_Ins == null)
            _Ins = new DataConnection();
        return _Ins;
    }
    set
    {
        _Ins = value;
    }
}
private static DataConnection _Ins;
private DataConnection()
{
    session = getConnect();
    session.Execute("use KeySpace;");
}

public ISession session;
private string IP = "x.x.x.4"; 
private string Datacenter = "datacenter1";
public ISession getConnect()
{
    return session = Cluster.Builder()
                         .AddContactPoints(IP)
                         .WithPort(9042)
                         .WithLoadBalancingPolicy(new DCAwareRoundRobinPolicy(Datacenter))
                         .Build()
                         .Connect();
}

And here the using part:

private void LoginBtnSubmit_Click(object sender, EventArgs e)
    {
        string query = "Query sth";

        Cassandra.RowSet row = DataConnection.Ins.session.Execute(query);
        if (row.FirstOrDefault() != null)
        {
            //Do sth
        }
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source