You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Manu Chadha <ma...@hotmail.com> on 2020/06/04 19:10:00 UTC
Unable to connect with Cassandra Docker image from outside
Hi
I want to run cassandra docker image and want to connect it with my application running in another container. I am on Windows10 and both containers are running on same Windows10 Home machine. I also have Cassandra installed on the machine as standalone application (without Docker).
I thought to use host.docker.internal as domain name in both the applications. But when I start cassandra image, I get error
org.apache.cassandra.exceptions.ConfigurationException: Unable to bind to address host.docker.internal/192.168.65.2:7000. Set listen_address in cassandra.yaml to an interface you can bind to, e.g., your private IP address on EC2
Question 1) Why is host.docker.internal resolving to 192.168.65.2/7000?. Shouldn't it be 192.168.1.12 as that is what is configured in my etc/hosts file on Windows 10
C:\Users\manuc>ping host.docker.internal
Pinging host.docker.internal [192.168.1.12] with 32 bytes of data:
Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
Reply from 192.168.1.12: bytes=32 time=1ms TTL=128
Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
I also tried explicitly specifying 192.168.1.12 when starting cassandra images but I get similar error.
The only way I am able to start the container is by running docker run ca795bbd8fd7 but in this case, cassandra listens at address 0.0.0.0 for cqlsh
Starting listening for CQL clients on /0.0.0.0:9042 (unencrypted)..
But in this case, my other docker application or cqlsh of the standalone CasSandra is unable to connect with it (running on the same windows machine)
C:\Users\manuc>cqlsh host.docker.internal 9042
Connection error: ('Unable to connect to any servers', {'192.168.1.12': error(10061, "Tried connecting to [('192.168.1.12', 9042)]. Last error: No connection could be made because the target machine actively refused it")})
C:\Users\manuc>cqlsh 0.0.0.0 9042
Connection error: ('Unable to connect to any servers', {'0.0.0.0': error(10049, "Tried connecting to [('0.0.0.0', 9042)]. Last error: The requested address is not valid in its context")})
C:\Users\manuc>docker run .. my_other_docker_application
[trace] s.d.c.CassandraConnectionManagementService - creating session with uri CassandraConnectionUri(cassandra://host.docker.internal:9042/myKeyspace) and cluster name Test Cluster
[trace] s.d.c.CassandraConnectionManagementService - exception in connecting with database com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: host.docker.internal/192.168.65.2:9042 (com.datastax.driver.core.exceptions.TransportException: [host.docker.internal/192.168.65.2:9042] Cannot connect))
Oops, cannot start the server.
play.api.libs.json.JsResult$Exception: {"obj":[{"msg":["Unable to connect with database"],"args":[]}]}
Question 2) How can I make Cassandra container connect with my other application container or cqlsh of my standalone Cassandra installation?
Thanks
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10