<p>I have a 3 Node cluster running on GCP in Kubernetes. I am able to forward the port and connect with my DB Tool to the cluster:</p>

<pre><code>$ kubectl port-forward elassandra-0 9042
</code></pre>

<p>When I try to connect to the cassandra cluster from my Spring Boot application, I get the following error:</p>

<pre><code>2018-11-14 17:43:36,339 INFO  [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.3.3:9042 added
2018-11-14 17:43:36,339 INFO  [5914] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /10.4.2.4:9042 added
2018-11-14 17:43:36,340 INFO  [5915] [localhost-startStop-1] c.d.d.c.Cluster [Cluster.java:1587] New Cassandra host /127.0.0.1:9042 added
2018-11-14 17:43:41,391 WARN  [10966] [cluster1-nio-worker-2] c.d.d.c.HostConnectionPool [HostConnectionPool.java:184] Error creating connection to /10.4.2.4:9042

com.datastax.driver.core.exceptions.TransportException: [/10.4.2.4:9042] Cannot connect
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:167)
at com.datastax.driver.core.Connection$1.operationComplete(Connection.java:150)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:121)
</code></pre>

<p>I am trying to connect to <code>127.0.0.1:9042</code>, the other hosts are being pulled from the cluster by the spring-data framework.</p>

<p>What am I doing wrong here?</p>

<p>Thanks.</p>

Alex Tbk
<p>To add more details since you have automatic address resolution enabled, your client it's trying to add contact points to all the nodes in your cluster:</p>

<pre><code>10.4.3.3:9042
10.4.2.4:9042
127.0.0.1:9042
</code></pre>

<p>However, the top 2 nodes cannot be found from your localhost because they are not being proxied to. If you added them as proxies it wouldn't work either because you can't proxy on the same port from your laptop.  The solution like @AlexTbk mentioned is to use a single contact point but specifying address resolution on the client with the single <code>127.0.0.1:9042</code> contact point.</p>
