1

I have set of microservices running as docker container. One microservice say A wants to connect to cassnadra running locally on my laptop. in order to do so i have below configurations

snippet from yaml file of service A

cassandra:
    hosts: [127.0.0.1]     
    keyspace: "My keyspace"
    protocol_version: 3
    ports: 9042

In other side i ran cassandra by calling ./bin/cassandra . and then i connected to cqlsh locally whose output is as below

Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.6 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.

now when my container comes up and try to connect to this running cassandra hosted on my machine it says as says connection refused . please see the trace below

File "cassandra/cluster.py", line 2076, in cassandra.cluster.ControlConnection._reconnect_internal (cassandra/cluster.c:36914)
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'127.0.0.1': ConnectionRefusedError(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
[start] application exit with code 1, killing container

more info I am using apache-cassandra-3.0.6.

Please advise. Thanks

Karn_way
  • 1,005
  • 3
  • 19
  • 42
  • How are you running docker-daemon in your local environment? If you are using Oracle virtual box or docker machine, can you ssh into the machine and check whether you can access the cassandra service? – Shibashis May 16 '16 at 23:42

1 Answers1

2

As Shibashis has mentioned, probably you cannot reach the host via docker container with 127.0.0.1

Please find the IP represented as HOST. How to get the IP address of the docker host from inside a docker container

Start the cassandra instance by changing the conf\cassandra.yaml

  • listen_address
  • rpc_address

to the recongnized HOST IP.

Hope it helps!

Community
  • 1
  • 1
chaitan64arun
  • 783
  • 8
  • 20