Hadi
Hadi

Reputation: 55

Could not connect to cassandra with cqlsh

I want to connect to cassandra but got this error:

$ bin/cqlsh
Connection error: ('Unable to connect to any servers', {'192.168.1.200': error(10061, "Tried connecting to [('192.168.1.200', 9042)]. Last error: No connection could be made because the target machine actively refused it")})

Upvotes: 1

Views: 7591

Answers (7)

LetsNoSQL
LetsNoSQL

Reputation: 1538

There is no special method to connect cqlsh it simple as below:-

$ bin/cqlsh 127.0.0.1(host IP) 9042 or $ bin/cqlsh 127.0.0.1(host IP) 9160 (if older version of Cassandra)

Don't forget to check port connectivity if you are connecting cqlsh to remote host. Also you can use username/password if you enabled by default it is disabled.

Upvotes: 0

Abhishek Kumar
Abhishek Kumar

Reputation: 53

I also had same problem. I applied many methods given on google and youtube but none of them worked in my case. Finally, I applied the following 3 steps and it worked in my case:-

  1. Create a folder without any space in C or D whichever is your system drive. eg:- C:\cassandra
  2. Install Cassandra in this folder instead of installing in"Program Files". After installation, it will be like this- C:\cassandra\apache-cassandra-3.11.6
  3. Copy python 2.7 installed in bin folder i.e.,C:\cassandra\apache-cassandra-3.11.6\bin

Now your program is ready for work.

Upvotes: 0

Anower Perves
Anower Perves

Reputation: 762

You need to mention host, user, password for cassandra cqlsh connection. Default cassandra cqlsh user is cassandra and password is cassandra.

$ bin/cqlsh <host> -u cassandra -p cassandra

Upvotes: 0

Pragyaditya Das
Pragyaditya Das

Reputation: 1696

Pretty simple.

The machine is actively refusing it because your system does not have cassandra running on it. Follow the following steps to completely get rid of this trouble :

  1. Install Cassandra from DataStax (Datastax-DDC; Cassandra version 3).
  2. Go to ~\installation\path\DataStax-DDC\apache-cassandra\bin.
  3. Open up cmd there. (Use Alt+F+P to open it if you are on windows 8 or later).
  4. type cassandra -f this will generate a lot of stuff on the window and you must get the last line as INFO 11:32:31 Created default superuser role 'cassandra'
  5. Now open another cmd window in the same folder.
  6. Type cqlsh

This should give you a prompt, without any error.

I also discovered that this error doesn't pop up if I use cassadra v2.x found here Archived version of Cassandra. I don't know why :( (If you find out please comment).

So, if the above steps do not work, you can always go back to Cassandra v2.x.

Cheers.

Upvotes: 2

Lukasz
Lukasz

Reputation: 2317

I run into the same problem. This worked for me.

Go to any directory for example E:\ (doesn't have to be the same disc as the cassandra installation)

Create the following directories

E:\cassandra\storage\commitlogs
E:\cassandra\storage\data
E:\cassandra\storage\savedcaches

Then go to your cassandra installations conf path. In my case.

D:\DataStax-DDC\apache-cassandra\conf

Open cassandra.yaml. Edit the lines containing: data_file_directories, commitlog_directory, saved_caches_directory to look like the code below (change paths accordingly to where you created the folders)

data_file_directories:
    - E:\cassandra\storage\data

commitlog_directory: E:\cassandra\storage\commitlog

saved_caches_directory: E:\cassandra\storage\savedcaches

Then open the cmd (I did it as administrator, but didn't check if it is necessary) to your cassandra installations bin path. In my case.

D:\DataStax-DDC\apache-cassandra\bin

run cassandra -f

Lots of stuff will be logged to your screen. You should now be able to run cqlsh and all other stuff without problems.

Edit: The operating system was windows10 64bit

Edit2: If it stops working after a while check if the service is till running using nodetool status. If it isn't follow this instruction.

Upvotes: 1

Abhishek Nalin
Abhishek Nalin

Reputation: 4607

I also faced the same problem on a Win32 windows 7 machine.

  1. Check if you have JAVA installed correctly and JAVA_HOME variable set.
  2. Once you have checked the java installation and set JAVA_HOME, uninstall Cassandra and install it again.

Hopefully this would solve the problem. Mine was solved after applying the above two steps.

Upvotes: 0

Pandemonium
Pandemonium

Reputation: 8390

Check if you have started Cassandra server, then provide the host and port as the arguments.

$ bin/cqlsh 127.0.0.1 4092

Upvotes: 1

Related Questions