1

I am trying to connect to a cassandra installation from a remote machine. Cassandra is running the thrift service on 9160 which is the default port. But I cannot connect the DB and I always get connection timed out exception. Here are the details.

  1. the app machine trying to connect to the DB is a CentOS 7 VM
  2. Cassandra is running on windows 10 on port 9160

I ran the nmap and netstat commands to see the status of the ports and these are the outputs that I got

x.y.z.z - IP of the machine where cassandra is running
a.b.c.d - IP of the machine where application is running

Ouput From running nmap from a.b.c.d:

Bash$ nmap -r -p 9160 x.y.z.z
Starting Nmap 6.40 ( http://nmap.org ) at 2018-05-30 04:02 PDT
Nmap scan report for x.y.z.z
Host is up (0.0016s latency).
PORT     STATE  SERVICE
9160/tcp closed apani1

When I run netstat on the DB machine(x.y.z.z) I see that the DB app is listening on 9160 port.

TCP    x.y.z.z:63572    stackoverflow:https    ESTABLISHED
TCP    x.y.z.z:63735    stackoverflow:https    ESTABLISHED
TCP    x.y.z.z:64856    stackoverflow:https    ESTABLISHED
TCP    127.0.0.1:6942         x.y.z.z:0      LISTENING
TCP    127.0.0.1:7000         x.y.z.z:0      LISTENING  
TCP    127.0.0.1:9042         x.y.z.z:0      LISTENING
TCP    127.0.0.1:9042         x.y.z.z:55317  ESTABLISHED
TCP    127.0.0.1:9042         x.y.z.z:55329  ESTABLISHED
TCP    127.0.0.1:9160         x.y.z.z:0      LISTENING
TCP    127.0.0.1:50135        x.y.z.z:50136  ESTABLISHED

I added an inbound rule specifically for port 9160 in the DB machine. but that didn't help and I still get the connection timed out error.

My question:

  1. Why is the DB machine not connection even though host is up and the port is listening?
  2. Why does the nmap command show the port as closed? I can see from the cassandra start up log that the thrift service is listening on the port 9160.
Thomas
  • 4,155
  • 5
  • 21
  • 28
Thiru
  • 13
  • 1
  • 3

1 Answers1

2

The database is listening on 127.0.0.1:9160. That means it is currently configured to listen for loopback IP address only. In other words, it only listens for connections originating from the same host.

The parameter you'll need in your cassandra.yaml file is rpc_address. Its default value is 127.0.0.1. To allow your application to connect to your Cassandra DB, you should set that parameter to value x.y.z.z, or to unset if you wish Cassandra to listen on all interfaces whose IP address is mapped to the hostname of the database server.

telcoM
  • 4,153
  • 12
  • 23