Can't connect to cassandra node from different host

Chamila Wijayarathna picture Chamila Wijayarathna · Jan 3, 2015 · Viewed 38.2k times · Source

I have a cassandra node at a machine. When I access cqlsh from the same machne it works properly.

But when I tried to connect to it's cqlsh using "192.x.x.x" from another machine, I'm getting an error saying

Connection error: ('Unable to connect to any servers', {'192.x.x.x': error(111, "Tried connecting to [('192.x.x.x', 9042)]. Last error: Connection refused")})

What is the reason for this? How can I fix it?

Answer

Nicola Ferraro picture Nicola Ferraro · Jan 3, 2015

Probably the remote Cassandra node is not bound to the external network interface but to the loopback one (this is the default configuration). You can ensure this by using "telnet thecassandrahost 9042" from the remote machine, it should not work.

In order to bind Cassandra to the external network interface you need to edit the cassandra.yaml configuration file and set the properties "listen_address" and "rpc_address" to your remote IP or "0.0.0.0" (not all versions of Cassandra support wildcard addresses).

Check also that the firewall is properly configured or disabled (sudo service iptables stop).