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 status

This 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: 0

The above "bad" concerns me. But it does return "Active." It seems like there is no major problem.

When I run "cqlsh" or "cqlsh" I get

Connection error: ('Unable to connect to any servers', {'': error(111, "Tried connecting to [('', 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

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

Nothing I do works. I expect to enter a different command prompt when I type in "cqlsh" or "cqlsh". But this does not happen. What do I do to have "cqlsh" work on an Ubuntu server?

  • Use code formatting for command output, please. – muru Dec 27 '17 at 3:36
  • Try sudo fuser -n tcp 9042, if it returns a pid, there is at least a process running and listening on this port. Then try also to connect to (askubuntu.com/a/754219/367444). – Harald Dec 27 '17 at 12:58
  • 1
    That sudo fuser -n tcp 9042 returns nothing. sudo service cassandra status shows the Cassandra service is active. cqlsh returns Connection error: ('Unable to connect to any servers', {'': error(111, "Tried connecting to [('', 9042)]. Last error: Connection refused")}) – Jermoe Dec 28 '17 at 6:49
  • I am facing this issue. I am using Ubuntu 16.04. cassandra service is active and installation completed successfuly. I have no other process running on port 9042. Still I can't connect to cassandra server. – Badis Merabet Feb 14 '18 at 20:54
  • if issue is resolved try to post answer . i was facing same issue. i checked all the stackoverflow questions and my issue is not resolved. – Umapathi Apr 17 '18 at 9:51

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 :


Changed it to another port: 7198.

This solution work for me.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.