Getting error: You specified datacenter1 as the local DC, but some contact points are from a different DC

I am using TestContainres in my app

        registry.add("cass.contact-points", cassandra::getContainerIpAddress);
        registry.add("cass.datacenter", cassandra::getLocalDatacenter);
        registry.add("cass.keyspace-name", "spring_cassandra"::toString);
        Integer val1 = cassandra.getMappedPort(9042);
        registry.add("cass.port", val1::toString);

my application.yml:

spring:
  cassandra:
    contact-points: ${cass.contact-points}
    port: ${cass.port}
    localDatacenter: ${cass.datacenter}
    keyspace-name: ${cass.keyspace-name}
    schema-action: CREATE_IF_NOT_EXISTS
    request.timeout: 10s
    connection: 
      connect-timeout: 10s
      init-query-timeout: 10s

I got this error

You specified datacenter1 as the local DC, but some contact points are from a different DC: Node(endPoint=localhost/127.0.0.1:57498, hostId=null, hashCode=154d0426)=null;

Can someone give me an advice?

Thanks in advance!

Leave a Comment