Search code examples
dockercassandracontainersdatagrip

Connecting Apache Cassandra to DataGrip


After I pull the image for Cassandra and run a container and create the database, I want to add its data source on DataGrip to manage the database from there. When I run the container I made it listen too the ports 9842. By typing the commands:

  • docker pull cassandra
  • docker run -d cassandra-node -p 9842:9842
  • docker exec -it cassandra-node bash

The host is localhost and I try to access the database with jdbc:cassandra://localhost:9842 URL.

I tried to connect, but every time I get the error:

All host(s) tried for query failed (tried: localhost/127.0.0.1:9842 (com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1:9842] Channel has been closed)).


Solution

  • If you run your container on localhost and did not change Cassandra's configuration Cassandra will start on port 9042 in the container. You should change your docker run command to

    docker run -d cassandra-node -p 9842:9042

    This binds port 9042 of the container to port 9842 on the host machine.