How do I get Cassandra to start when there is an error about "Connection refused"?
Andrew Mclaughlin
I installed Cassandra on Ubuntu 16.04. (I have gotten Cassandra to work on RedHat. But now I want it to work on Ubuntu.) The installation seemed to go smoothly. I run this command to prove that Cassandra is active:
sudo service cassandra statusThis command returns this output:
cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/init.d/cassandra; bad; vendor preset: enabled)
Active: active (exited) since Tue 2017-12-26 19:22:43 UTC; 8min ago
Docs: man:systemd-sysv-generator(8) Process: 1252 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS)
Tasks: 0 Memory: 0B CPU: 0The above "bad" concerns me. But it does return "Active." It seems like there is no major problem.
When I run "cqlsh" or "cqlsh 127.0.0.1" I get
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
I used nmap to test port 9042. The port is not blocked. There is not firewall installed either.
I rebooted the server. I tried modifying cassandra-env.sh. I uncommented a stanza and set it to be 127.0.0.1:
JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=127.0.0.1"Nothing I do works. I expect to enter a different command prompt when I type in "cqlsh" or "cqlsh 127.0.0.1". But this does not happen. What do I do to have "cqlsh" work on an Ubuntu server?
61 Answer
If you look at /var/log/cassandra/system.log you'll see:
Port already in use: 7199; nested exception is:java.net.BindException: Address already in use (Bind failed)
This is the default port in /etc/cassandra/cassandra-env.sh :
JMX_PORT="7199"
Changed it to another port: 7198.
This solution work for me.