NoHostAvailableError: All host(s) tried for query failed. First host tried, 127.0.0.1:9042: Error: connect ECONNREFUSED 127.0.0.1:9042

NoHostAvailableError: All host(s) tried for query failed. First host tried, 127.0.0.1:9042: Error: connect ECONNREFUSED 127.0.0.1:9042


Why `All host(s) tried for query failed`?

All host(s) tried for query failed occured, because the app could you find any Cassandra node to connect to.

What is the fix?

In order to fix this, we need to configure the cassandra.yaml file. You can find the file in /etc/cassandra/cassandra.yaml.

Once you've located your cassandra.yaml, we need to find the `rpc_address` located in the cassandra.yaml file. What `rpc_address` do is, it defines from which client should the Cassandra node listens to. So if you are creating a Node JS server with an IP address of, let's say, 192.168.1.1, the `rpc_address` should match that. By default, the `rpc_address` is set to 0.0.0.0. In order to fix it, find out what IP address your server is using, and set it to the `rpc_address`. 

Note that localhost, nor the default IP would work if you run your Cassandra node in Docker. Therefore, you should use the IP address specified in your `ipconfig` that can be found when you run the command, `ipconfig` in your command prompt.

Comments

Popular posts from this blog

Support for the experimental syntax 'decorators' isn't currently enabled (5:3):

How to add environment variables into Heroku container

Running CQL scripts in Cassandra