Can't connect to the node

hello, I am new to scylla (and docker so maybe the problem is with my docker command )
I am trying to connect from my rust code to the scylla node that I run from docker
my docker command is docker run --name some-scylla -d scylladb/scylla --smp 1
and I simply have this fn to connect

/// Connect to a Scylla node
pub async fn connect_scylla_node(node: SocketAddr) -> Arc<Session> {
    let client = SessionBuilder::new()
        .known_node_addr(node)
        // .compression(Some(scylla::frame::Compression::Lz4))
        // .user("cassandra", "cassandra")
        .build()
        .await
        .unwrap();
    Arc::new(client)

}

and it giving me always this error

called `Result::unwrap()` on an `Err` value: ConnectionPoolError(Broken { last_connection_error: ConnectTimeout })

I forgot to mention
I pass this socket_addr

pub const A: SocketAddr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(172, 17, 0, 2), 9042));

so I seems to fix the connection by running this docker command

docker run  --name scyllnw --rm -it -p 9042:9042 scylladb/scylla --smp 2

and changed the socket_addr to localhost

but now I am wondering why I couldn’t connect to the private ip I got from the docker vm ? it in my network .
it seems I need use the docker port mapping .

What operating system do you use?
Do you use docker or podman?

I am using macOS, and docker

This is a known behavior of docker on MacOS and Windows - you can’t connect to internal docker IPs from outside on those systems.

so even if it private ip I have to map it to my address to communicate with the container?

Alternatively you could also run your application in the docker container.

that an option too,
thank you for helping me out !

1 Like

Private IP likely failed due to Docker’s networking isolation.

1 Like