Jul 6, 2015

nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused'. (Cassandra)


Error While Using Cassandra’s 'nodetool'

This error may occur when using the 'nodetool' command, such as in the following example:

$ nodetool status

For both CentOS 6 and CentOS 7 search the following configuration file:

cassandra-env.sh


This will be inside your <cassandra_home>/conf/ directory
Open this file in edit mode (Make sure you have permission to edit this file. Here I am a root user, so I have permission to edit it)

$ vim <cassandra_home>/conf/cassandra-env.sh


Tips: If you couldn't find this file, use 'locate' command to get the file location.
$ locate cassandra-env.sh


Once you open the file in edit mode, search for:

JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=

Which will probably result in:

# add this if you’re having trouble connecting:
# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>"


Uncomment the second line, and add the hostname of your server (replace <public name> with the IP/hostname), or the IP address which you’re connecting to/from.

Then exit and save the file.

Final Note:
Make Sure to restart Cassandra once the changes are done.

2 comments: