title: Unable to connect to Cassandra cluster running on local host
body: <p>I have setup datastax cassandra service and have created a keyspace and my db is running fine.</p>
  <p>Below are output from the nodetool status command:</p>
  <pre><code>C:\Users\xxx&gt;cd C:\Program Files\DataStax Community\apache-cassandra\bin
  
  C:\Program Files\DataStax Community\apache-cassandra\bin&gt;nodetool status
  Datacenter: datacenter1
  ========================
  Status=Up/Down
  |/ State=Normal/Leaving/Joining/Moving
  --  Address    Load       Tokens       Owns (effective)  Host ID                               Rack
  UN  127.0.0.1  229 KB     256          100.0%            d5229669-f8f2-4b06-a887-4ab91a883a74  rack1
  </code></pre>
  <p>Also , the data is created having a keyspace.</p>
  <pre><code>cqlsh:axiaglobal&gt; use axiaglobal;
  cqlsh:axiaglobal&gt; describe tables;
  
  greetings
  
  cqlsh:axiaglobal&gt; select * from greetings;
  
   user | id | creation_date | greet
  ------+----+---------------+-------
  </code></pre>
  <p>Now when I try to connect to cassandra via Java I get the following exception:</p>
  <pre><code>com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9042 (null))
      at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:196)
      at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79)
      at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1104)
      at com.datastax.driver.core.Cluster.init(Cluster.java:121)
      at com.datastax.driver.core.Cluster.connect(Cluster.java:198)
      at com.datastax.driver.core.Cluster.connect(Cluster.java:226)
      at com.axia.global.dao.cassandra.service.CassandraApp.main(CassandraApp.java:29)
  </code></pre>
  <p>Piece of code which makes a call to Cassandra is listed below:</p>
  <pre><code>package com.axia.global.dao.cassandra.service;
  
  import java.net.InetAddress;
  import java.net.UnknownHostException;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.data.cassandra.core.CassandraOperations;
  import org.springframework.data.cassandra.core.CassandraTemplate;
  
  import com.axia.global.model.cassandra.Person;
  import com.datastax.driver.core.Cluster;
  import com.datastax.driver.core.Session;
  import com.datastax.driver.core.querybuilder.QueryBuilder;
  import com.datastax.driver.core.querybuilder.Select;
  
  public class CassandraApp {
  
       private static final Logger LOG = LoggerFactory.getLogger(CassandraApp.class);
  
       private static Cluster cluster;
       private static Session session;
  
       public static void main(String[] args) {
  
        try {
         cluster = Cluster.builder().addContactPoints(&quot;127.0.0.1&quot;).build();
  
         session = cluster.connect(&quot;axiaglobal&quot;);
  
         CassandraOperations cassandraOps = new CassandraTemplate(session);
  
         Select s = QueryBuilder.select().from(&quot;greetings&quot;);
         
  
        } catch (Exception e) {
         e.printStackTrace();
        }
  
       }
      }
  </code></pre>
  <p>I am unable to understand where I am going wrong and why my connection is failing to connect to cassandra
  can some one help me out with it ?</p>
  <p>I have tried setting up the following:</p>
  <pre><code>rpc_address: 0.0.0.0 broadcast_rpc_address: 1.2.3.4 and even it did not work.
  </code></pre>