Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra cqlsh Unable to connect to any servers - 127.0.0.1:9160 (closed)> is already closed

I installed Cassandra on OSX. When trying to run cqlsh from /bin/, I get the following error:

> Connection error: ('Unable to connect to any servers', {'127.0.0.1':
> ConnectionShutdown('Connection <AsyncoreConnection(4522252560)
> 127.0.0.1:9160 (closed)> is already closed',)})

I had difficulty installing Cassandra, and had used brew install cassandra, installed DSE from datastax, and downloaded a binary from Apache.

like image 402
Peter Dietz Avatar asked Nov 18 '14 21:11

Peter Dietz


4 Answers

I think the issue was the result of having a previous installation that wasn't properly uninstalled. My user .cassandra directory had some default configs, that must have been for a different version, and prevented cqlsh from starting.

rm -Rf ~/.cassandra

After that, I could run cqlsh properly.

$ bin/cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3]
Use HELP for help.
cqlsh> 
like image 138
Peter Dietz Avatar answered Nov 15 '22 13:11

Peter Dietz


Running cassandra helped me to troubleshot the problem:

> cassandra
Cassandra 3.0 and later require Java 8u40 or later.

and:

> java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-3)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)

After installing Java 8 it worked.

like image 31
Eric Saboia Avatar answered Nov 15 '22 13:11

Eric Saboia


Cassandra-2.1 uses 9042 as cqlsh port.Connect on this it is default port.If you want to connect on 9160 port then change it by setting environment variable CQLSH_PORT and CQLSH_HOST but for setting this you have to change rpc_port from default 9160 to any other port.

like image 32
hemendra kumar Avatar answered Nov 15 '22 13:11

hemendra kumar


Well, I faced same issue and this is what i did on Mac.

$cd /usr/local/Cellar/cassandra/3.10_1/bin/     

Or wherever your cassandra is installed.

$cassandra 

this initializes all configuration in your local system to start cassandra.

$./cqlsh 

This lets you enter cql query mode.

like image 33
nik_7 Avatar answered Nov 15 '22 14:11

nik_7