# NoNodeAvailableException

**URL:** <https://discuss.elastic.co/t/nonodeavailableexception/6223>\
**Category:** Elasticsearch\
**Created:** [December 22, 2011, 5:27pm UTC](https://discuss.elastic.co/t/nonodeavailableexception/6223 "2011-12-22T17:27:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Loehr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_loehr/32/2708_2.png) [@David\_Loehr](https://discuss.elastic.co/u/David_Loehr)\
**Post date:** [December 22, 2011, 5:27pm UTC](https://discuss.elastic.co/t/nonodeavailableexception/6223/1 "2011-12-22T17:27:53Z")

</div>

Hello,

I'm having trouble connecting to elasticsearch through the Java API. I  
have two servers, each running elastic search and my java application  
(Play! Framework). I can connect to elasticsearch using curl on port  
9200, for example:  
$ curl -XGET server1:9200/\_cluster/health  
{"cluster\_name":"elasticsearch","status":"yellow","timed\_out":false,"number\_of\_nodes":  
1,"number\_of\_data\_nodes":1,"active\_primary\_shards":5,"active\_shards":  
5,"relocating\_shards":0,"initializing\_shards":0,"unassigned\_shards":5}

But when I try to connect with the Java API on port 9300, I get a  
NoNodeAvailableException. I've opened ports 9200 and 9300 on my  
firewall. The ES log on each server, and the cluster health above,  
seem to indicate that the two instances of elastic search aren't  
connecting to each other. I read in a few other threads that this is  
often caused by mismatched cluster names, but I'm using the default  
value, "elasticsearch".

What am I doing wrong?

Stack trace:  
play.exceptions.JavaExecutionException: No node available  
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)  
at Invocation.HTTP Request(Play!)  
Caused by:  
org.elasticsearch.client.transport.NoNodeAvailableException: No node  
available  
at  
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:  
145)  
at  
org.elasticsearch.client.transport.support.InternalTransportClusterAdminClient.state(InternalTransportClusterAdminClient.java:  
125)  
at controllers.Search.index(Search.java:36)

/etc/elasticsearch/elasticsearch.yml config file (Elastic search is  
set up as a service, as described at  
[http://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elasticsearch-on-debian.html](http://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elasticsearch-on-debian.html)):  
cluster:  
name: elasticsearch  
network:  
host: _eth1:ipv4_

Elastic Search logs:  
Server 1:  
[2011-12-22 16:47:25,350][INFO][node] [Fight-  
Man] {0.18.6}[1605]: initializing ...  
[2011-12-22 16:47:25,365][INFO][plugins] [Fight-  
Man] loaded [], sites []  
[2011-12-22 16:47:28,228][INFO][node] [Fight-  
Man] {0.18.6}[1605]: initialized  
[2011-12-22 16:47:28,229][INFO][node] [Fight-  
Man] {0.18.6}[1605]: starting ...  
[2011-12-22 16:47:28,324][INFO][transport] [Fight-  
Man] bound\_address {inet[/10.182.35.60:9300]}, publish\_address {inet[/  
10.182.1.2:9300]}  
[2011-12-22 16:47:31,369][INFO][cluster.service] [Fight-  
Man] new\_master [Fight-Man][D\_A18QcATlaFPE28FI5-gg][inet[/  
10.182.1.2:9300]], reason: zen-disco-join (elected\_as\_master)  
[2011-12-22 16:47:31,444][INFO][discovery] [Fight-  
Man] elasticsearch/D\_A18QcATlaFPE28FI5-gg  
[2011-12-22 16:47:31,678][INFO][http] [Fight-  
Man] bound\_address {inet[/10.182.35.60:9200]}, publish\_address {inet[/  
10.182.1.2:9200]}  
[2011-12-22 16:47:31,679][INFO][node] [Fight-  
Man] {0.18.6}[1605]: started  
[2011-12-22 16:47:32,393][INFO][gateway] [Fight-  
Man] recovered [1] indices into cluster\_state

Server 2:  
[2011-12-22 16:52:10,402][INFO][node] [Jack-in-  
the-Box] {0.18.6}[1799]: initializing ...  
[2011-12-22 16:52:10,411][INFO][plugins] [Jack-in-  
the-Box] loaded [], sites []  
[2011-12-22 16:52:13,505][INFO][node] [Jack-in-  
the-Box] {0.18.6}[1799]: initialized  
[2011-12-22 16:52:13,507][INFO][node] [Jack-in-  
the-Box] {0.18.6}[1799]: starting ...  
[2011-12-22 16:52:13,659][INFO][transport] [Jack-in-  
the-Box] bound\_address {inet[/10.182.33.113:9300]}, publish\_address  
{inet[/10.182.3.4:9300]}  
[2011-12-22 16:52:16,815][INFO][cluster.service] [Jack-in-  
the-Box] new\_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/  
10.182.3.4:9300]], reason: zen-disco-join (elected\_as\_master)  
[2011-12-22 16:52:16,857][INFO][discovery] [Jack-in-  
the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw  
[2011-12-22 16:52:16,950][INFO][http] [Jack-in-  
the-Box] bound\_address {inet[/10.182.33.113:9200]}, publish\_address  
{inet[/10.182.3.4:9200]}  
[2011-12-22 16:52:16,953][INFO][node] [Jack-in-  
the-Box] {0.18.6}[1799]: started  
[2011-12-22 16:52:16,967][INFO][gateway] [Jack-in-  
the-Box] recovered [0] indices into cluster\_state

My Java code:  
public class Search extends Controller {

```
@Get("/cluster")
public static void index() {
    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", "elasticsearch").build();
    TransportClient client = new TransportClient(settings)
        .addTransportAddress(new

```

InetSocketTransportAddress("10.182.1.2", 9300))  
.addTransportAddress(new  
InetSocketTransportAddress("10.182.3.4", 9300));  
ActionFuture response =  
client.admin().cluster().state(new ClusterStateRequest()); // Throws  
exception  
renderText(response.actionGet().getClusterName().toString());  
}

```
@Get("/cluster/node")
public static void node() {
    Node node = nodeBuilder().data(false).node();
    Client client = node.client();
    ActionFuture<ClusterStateResponse> response =

```

client.admin().cluster().state(new ClusterStateRequest());

renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //  
Output is []  
}  
}

iptables rules:  
ACCEPT tcp -- server1 anywhere tcp dpt:9200  
ACCEPT tcp -- server2 anywhere tcp dpt:9200  
ACCEPT udp -- server1 anywhere udp dpt:9300  
ACCEPT udp -- server2 anywhere udp dpt:9300  
ACCEPT tcp -- server1 anywhere tcp dpt:9300  
ACCEPT tcp -- server2 anywhere tcp dpt:9300

---

<div class="post-metadata">

**Author:** ![David\_Loehr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_loehr/32/2708_2.png) [@David\_Loehr](https://discuss.elastic.co/u/David_Loehr)\
**Post date:** [December 22, 2011, 9:44pm UTC](https://discuss.elastic.co/t/nonodeavailableexception/6223/2 "2011-12-22T21:44:13Z")

</div>

I now have the two nodes communicating with each other, but am still  
unable to access them through the Java API's TransportClient.

My servers are in Rackspace, and since multicast is disabled there, I  
needed to use unicast to get them to discover each other:  
discovery:  
zen:  
ping:  
multicast:  
enabled: false  
unicast:  
hosts: "server1:9300,server2:9300"

The second server to start now detects the other as the master, and  
through curl, I can see that what I PUT to one, I can GET from the  
other.

What settings do I need to use when setting up the TransportClient? Do  
I need unicast here? I'm currently doing the following:

```
    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", "elasticsearch")
        .put("client.transport.sniff", true)
        .put("discovery.zen.ping.multicast.enabled", false)
        .put("discovery.zen.ping.unicast.enabled", true)
        .put("discovery.zen.ping.unicast.hosts",

```

"server1:9300,server2:9300")  
.put("discovery.zen.multicast.enabled", false)  
.put("discovery.zen.unicast.enabled", true)  
.put("discovery.zen.unicast.hosts",  
"server1:9300,server2:9300").build();  
TransportClient client = new TransportClient(settings)  
.addTransportAddress(new  
InetSocketTransportAddress("server1", 9300))  
.addTransportAddress(new  
InetSocketTransportAddress("server2", 9300));  
NodesInfoResponse rsp = client.admin().cluster().nodesInfo(new  
NodesInfoRequest()).actionGet();  
String str = "Cluster:" + rsp.getClusterName() + ". Active  
nodes:";  
str += rsp.getNodesMap().keySet();  
renderText(str);

On Dec 22, 12:27 pm, David Loehr [dlo...@servicetask.com](mailto:dlo...@servicetask.com) wrote:

> Hello,
> 
> I'm having trouble connecting to elasticsearch through the Java API. I  
> have two servers, each running Elasticsearch and my java application  
> (Play! Framework). I can connect to elasticsearch using curl on port  
> 9200, for example:  
> $ curl -XGET server1:9200/\_cluster/health  
> {"cluster\_name":"elasticsearch","status":"yellow","timed\_out":false,"number \_of\_nodes":  
> 1,"number\_of\_data\_nodes":1,"active\_primary\_shards":5,"active\_shards":  
> 5,"relocating\_shards":0,"initializing\_shards":0,"unassigned\_shards":5}
> 
> But when I try to connect with the Java API on port 9300, I get a  
> NoNodeAvailableException. I've opened ports 9200 and 9300 on my  
> firewall. The ES log on each server, and the cluster health above,  
> seem to indicate that the two instances of Elasticsearch aren't  
> connecting to each other. I read in a few other threads that this is  
> often caused by mismatched cluster names, but I'm using the default  
> value, "elasticsearch".
> 
> What am I doing wrong?
> 
> Stack trace:  
> play.exceptions.JavaExecutionException: No node available  
> at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)  
> at Invocation.HTTP Request(Play!)  
> Caused by:  
> org.elasticsearch.client.transport.NoNodeAvailableException: No node  
> available  
> at  
> org.elasticsearch.client.transport.TransportClientNodesService.execute(Tran sportClientNodesService.java:  
> 145)  
> at  
> org.elasticsearch.client.transport.support.InternalTransportClusterAdminCli ent.state(InternalTransportClusterAdminClient.java:  
> 125)  
> at controllers.Search.index(Search.java:36)
> 
> /etc/elasticsearch/elasticsearch.yml config file (Elastic search is  
> set up as a service, as described athttp://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elastics...  
> cluster:  
> name: elasticsearch  
> network:  
> host: _eth1:ipv4_
> 
> Elastic Search logs:  
> Server 1:  
> [2011-12-22 16:47:25,350][INFO][node] [Fight-  
> Man] {0.18.6}[1605]: initializing ...  
> [2011-12-22 16:47:25,365][INFO][plugins] [Fight-  
> Man] loaded , sites   
> [2011-12-22 16:47:28,228][INFO][node] [Fight-  
> Man] {0.18.6}[1605]: initialized  
> [2011-12-22 16:47:28,229][INFO][node] [Fight-  
> Man] {0.18.6}[1605]: starting ...  
> [2011-12-22 16:47:28,324][INFO][transport] [Fight-  
> Man] bound\_address {inet[/10.182.35.60:9300]}, publish\_address {inet[/  
> 10.182.1.2:9300]}  
> [2011-12-22 16:47:31,369][INFO][cluster.service] [Fight-  
> Man] new\_master [Fight-Man][D\_A18QcATlaFPE28FI5-gg][inet[/  
> 10.182.1.2:9300]], reason: zen-disco-join (elected\_as\_master)  
> [2011-12-22 16:47:31,444][INFO][discovery] [Fight-  
> Man] elasticsearch/D\_A18QcATlaFPE28FI5-gg  
> [2011-12-22 16:47:31,678][INFO][http] [Fight-  
> Man] bound\_address {inet[/10.182.35.60:9200]}, publish\_address {inet[/  
> 10.182.1.2:9200]}  
> [2011-12-22 16:47:31,679][INFO][node] [Fight-  
> Man] {0.18.6}[1605]: started  
> [2011-12-22 16:47:32,393][INFO][gateway] [Fight-  
> Man] recovered [1] indices into cluster\_state
> 
> Server 2:  
> [2011-12-22 16:52:10,402][INFO][node] [Jack-in-  
> the-Box] {0.18.6}[1799]: initializing ...  
> [2011-12-22 16:52:10,411][INFO][plugins] [Jack-in-  
> the-Box] loaded , sites   
> [2011-12-22 16:52:13,505][INFO][node] [Jack-in-  
> the-Box] {0.18.6}[1799]: initialized  
> [2011-12-22 16:52:13,507][INFO][node] [Jack-in-  
> the-Box] {0.18.6}[1799]: starting ...  
> [2011-12-22 16:52:13,659][INFO][transport] [Jack-in-  
> the-Box] bound\_address {inet[/10.182.33.113:9300]}, publish\_address  
> {inet[/10.182.3.4:9300]}  
> [2011-12-22 16:52:16,815][INFO][cluster.service] [Jack-in-  
> the-Box] new\_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/  
> 10.182.3.4:9300]], reason: zen-disco-join (elected\_as\_master)  
> [2011-12-22 16:52:16,857][INFO][discovery] [Jack-in-  
> the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw  
> [2011-12-22 16:52:16,950][INFO][http] [Jack-in-  
> the-Box] bound\_address {inet[/10.182.33.113:9200]}, publish\_address  
> {inet[/10.182.3.4:9200]}  
> [2011-12-22 16:52:16,953][INFO][node] [Jack-in-  
> the-Box] {0.18.6}[1799]: started  
> [2011-12-22 16:52:16,967][INFO][gateway] [Jack-in-  
> the-Box] recovered [0] indices into cluster\_state
> 
> My Java code:  
> public class Search extends Controller {
> 
> ```
> @Get("/cluster")
> public static void index() {
> Settings settings = ImmutableSettings.settingsBuilder()
> .put("cluster.name", "elasticsearch").build();
> TransportClient client = new TransportClient(settings)
> .addTransportAddress(new
> 
> ```
> 
> InetSocketTransportAddress("10.182.1.2", 9300))  
> .addTransportAddress(new  
> InetSocketTransportAddress("10.182.3.4", 9300));  
> ActionFuture response =  
> client.admin().cluster().state(new ClusterStateRequest()); // Throws  
> exception  
> renderText(response.actionGet().getClusterName().toString());  
> }
> 
> ```
> @Get("/cluster/node")
> public static void node() {
> Node node = nodeBuilder().data(false).node();
> Client client = node.client();
> ActionFuture<ClusterStateResponse> response =
> 
> ```
> 
> client.admin().cluster().state(new ClusterStateRequest());
> 
> renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //  
> Output is   
> }
> 
> }
> 
> iptables rules:  
> ACCEPT tcp -- server1 anywhere tcp dpt:9200  
> ACCEPT tcp -- server2 anywhere tcp dpt:9200  
> ACCEPT udp -- server1 anywhere udp dpt:9300  
> ACCEPT udp -- server2 anywhere udp dpt:9300  
> ACCEPT tcp -- server1 anywhere tcp dpt:9300  
> ACCEPT tcp -- server2 anywhere tcp dpt:9300

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 22, 2011, 11:51pm UTC](https://discuss.elastic.co/t/nonodeavailableexception/6223/3 "2011-12-22T23:51:55Z")

</div>

Transport client does not need the zen discovery settings to be applied to  
it, since it does no discovery. It connects directly to the provided  
servers. You can set org.elasticsearch.client.transport to TRACE level in  
your logging configuration (on the client side) to see the failures it has  
(to connect for example).

On Thu, Dec 22, 2011 at 11:44 PM, David Loehr [dloehr@servicetask.com](mailto:dloehr@servicetask.com)wrote:

> I now have the two nodes communicating with each other, but am still  
> unable to access them through the Java API's TransportClient.
> 
> My servers are in Rackspace, and since multicast is disabled there, I  
> needed to use unicast to get them to discover each other:  
> discovery:  
> zen:  
> ping:  
> multicast:  
> enabled: false  
> unicast:  
> hosts: "server1:9300,server2:9300"
> 
> The second server to start now detects the other as the master, and  
> through curl, I can see that what I PUT to one, I can GET from the  
> other.
> 
> What settings do I need to use when setting up the TransportClient? Do  
> I need unicast here? I'm currently doing the following:
> 
> ```
> Settings settings = ImmutableSettings.settingsBuilder()
> .put("cluster.name", "elasticsearch")
> .put("client.transport.sniff", true)
> .put("discovery.zen.ping.multicast.enabled", false)
> .put("discovery.zen.ping.unicast.enabled", true)
> .put("discovery.zen.ping.unicast.hosts",
> 
> ```
> 
> "server1:9300,server2:9300")  
> .put("discovery.zen.multicast.enabled", false)  
> .put("discovery.zen.unicast.enabled", true)  
> .put("discovery.zen.unicast.hosts",  
> "server1:9300,server2:9300").build();  
> TransportClient client = new TransportClient(settings)  
> .addTransportAddress(new  
> InetSocketTransportAddress("server1", 9300))  
> .addTransportAddress(new  
> InetSocketTransportAddress("server2", 9300));  
> NodesInfoResponse rsp = client.admin().cluster().nodesInfo(new  
> NodesInfoRequest()).actionGet();  
> String str = "Cluster:" + rsp.getClusterName() + ". Active  
> nodes:";  
> str += rsp.getNodesMap().keySet();  
> renderText(str);
> 
> On Dec 22, 12:27 pm, David Loehr [dlo...@servicetask.com](mailto:dlo...@servicetask.com) wrote:
> 
> > Hello,
> > 
> > I'm having trouble connecting to elasticsearch through the Java API. I  
> > have two servers, each running Elasticsearch and my java application  
> > (Play! Framework). I can connect to elasticsearch using curl on port  
> > 9200, for example:  
> > $ curl -XGET server1:9200/\_cluster/health
> 
> {"cluster\_name":"elasticsearch","status":"yellow","timed\_out":false,"number  
> \_of\_nodes":
> 
> > 1,"number\_of\_data\_nodes":1,"active\_primary\_shards":5,"active\_shards":  
> > 5,"relocating\_shards":0,"initializing\_shards":0,"unassigned\_shards":5}
> > 
> > But when I try to connect with the Java API on port 9300, I get a  
> > NoNodeAvailableException. I've opened ports 9200 and 9300 on my  
> > firewall. The ES log on each server, and the cluster health above,  
> > seem to indicate that the two instances of Elasticsearch aren't  
> > connecting to each other. I read in a few other threads that this is  
> > often caused by mismatched cluster names, but I'm using the default  
> > value, "elasticsearch".
> > 
> > What am I doing wrong?
> > 
> > Stack trace:  
> > play.exceptions.JavaExecutionException: No node available  
> > at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)  
> > at Invocation.HTTP Request(Play!)  
> > Caused by:  
> > org.elasticsearch.client.transport.NoNodeAvailableException: No node  
> > available  
> > at
> 
> org.elasticsearch.client.transport.TransportClientNodesService.execute(Tran  
> sportClientNodesService.java:
> 
> > 1. at
> 
> org.elasticsearch.client.transport.support.InternalTransportClusterAdminCli  
> ent.state(InternalTransportClusterAdminClient.java:
> 
> > 1. at controllers.Search.index(Search.java:36)
> > 
> > /etc/elasticsearch/elasticsearch.yml config file (Elastic search is  
> > set up as a service, as described athttp://  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elastics)...  
> > cluster:  
> > name: elasticsearch  
> > network:  
> > host: _eth1:ipv4_
> > 
> > Elastic Search logs:  
> > Server 1:  
> > [2011-12-22 16:47:25,350][INFO][node] [Fight-  
> > Man] {0.18.6}[1605]: initializing ...  
> > [2011-12-22 16:47:25,365][INFO][plugins] [Fight-  
> > Man] loaded , sites   
> > [2011-12-22 16:47:28,228][INFO][node] [Fight-  
> > Man] {0.18.6}[1605]: initialized  
> > [2011-12-22 16:47:28,229][INFO][node] [Fight-  
> > Man] {0.18.6}[1605]: starting ...  
> > [2011-12-22 16:47:28,324][INFO][transport] [Fight-  
> > Man] bound\_address {inet[/10.182.35.60:9300]}, publish\_address {inet[/  
> > 10.182.1.2:9300]}  
> > [2011-12-22 16:47:31,369][INFO][cluster.service] [Fight-  
> > Man] new\_master [Fight-Man][D\_A18QcATlaFPE28FI5-gg][inet[/  
> > 10.182.1.2:9300]], reason: zen-disco-join (elected\_as\_master)  
> > [2011-12-22 16:47:31,444][INFO][discovery] [Fight-  
> > Man] elasticsearch/D\_A18QcATlaFPE28FI5-gg  
> > [2011-12-22 16:47:31,678][INFO][http] [Fight-  
> > Man] bound\_address {inet[/10.182.35.60:9200]}, publish\_address {inet[/  
> > 10.182.1.2:9200]}  
> > [2011-12-22 16:47:31,679][INFO][node] [Fight-  
> > Man] {0.18.6}[1605]: started  
> > [2011-12-22 16:47:32,393][INFO][gateway] [Fight-  
> > Man] recovered [1] indices into cluster\_state
> > 
> > Server 2:  
> > [2011-12-22 16:52:10,402][INFO][node] [Jack-in-  
> > the-Box] {0.18.6}[1799]: initializing ...  
> > [2011-12-22 16:52:10,411][INFO][plugins] [Jack-in-  
> > the-Box] loaded , sites   
> > [2011-12-22 16:52:13,505][INFO][node] [Jack-in-  
> > the-Box] {0.18.6}[1799]: initialized  
> > [2011-12-22 16:52:13,507][INFO][node] [Jack-in-  
> > the-Box] {0.18.6}[1799]: starting ...  
> > [2011-12-22 16:52:13,659][INFO][transport] [Jack-in-  
> > the-Box] bound\_address {inet[/10.182.33.113:9300]}, publish\_address  
> > {inet[/10.182.3.4:9300]}  
> > [2011-12-22 16:52:16,815][INFO][cluster.service] [Jack-in-  
> > the-Box] new\_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/  
> > 10.182.3.4:9300]], reason: zen-disco-join (elected\_as\_master)  
> > [2011-12-22 16:52:16,857][INFO][discovery] [Jack-in-  
> > the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw  
> > [2011-12-22 16:52:16,950][INFO][http] [Jack-in-  
> > the-Box] bound\_address {inet[/10.182.33.113:9200]}, publish\_address  
> > {inet[/10.182.3.4:9200]}  
> > [2011-12-22 16:52:16,953][INFO][node] [Jack-in-  
> > the-Box] {0.18.6}[1799]: started  
> > [2011-12-22 16:52:16,967][INFO][gateway] [Jack-in-  
> > the-Box] recovered [0] indices into cluster\_state
> > 
> > My Java code:  
> > public class Search extends Controller {
> > 
> > ```
> > @Get("/cluster")
> > public static void index() {
> > Settings settings = ImmutableSettings.settingsBuilder()
> > .put("cluster.name", "elasticsearch").build();
> > TransportClient client = new TransportClient(settings)
> > .addTransportAddress(new
> > 
> > ```
> > 
> > InetSocketTransportAddress("10.182.1.2", 9300))  
> > .addTransportAddress(new  
> > InetSocketTransportAddress("10.182.3.4", 9300));  
> > ActionFuture response =  
> > client.admin().cluster().state(new ClusterStateRequest()); // Throws  
> > exception  
> > renderText(response.actionGet().getClusterName().toString());  
> > }
> > 
> > ```
> > @Get("/cluster/node")
> > public static void node() {
> > Node node = nodeBuilder().data(false).node();
> > Client client = node.client();
> > ActionFuture<ClusterStateResponse> response =
> > 
> > ```
> > 
> > client.admin().cluster().state(new ClusterStateRequest());
> 
> renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //
> 
> > Output is   
> > }
> > 
> > }
> > 
> > iptables rules:  
> > ACCEPT tcp -- server1 anywhere tcp dpt:9200  
> > ACCEPT tcp -- server2 anywhere tcp dpt:9200  
> > ACCEPT udp -- server1 anywhere udp dpt:9300  
> > ACCEPT udp -- server2 anywhere udp dpt:9300  
> > ACCEPT tcp -- server1 anywhere tcp dpt:9300  
> > ACCEPT tcp -- server2 anywhere tcp dpt:9300

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 22, 2011, 11:59pm UTC](https://discuss.elastic.co/t/nonodeavailableexception/6223/4 "2011-12-22T23:59:52Z")

</div>

Also, try and set sniff to false (the default). When sniffing it turned on,  
it will try to connect to the publish host of each node (its logged on each  
node when it starts up), which might not be the IP you want to connect  
through.

On Fri, Dec 23, 2011 at 1:51 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Transport client does not need the zen discovery settings to be applied to  
> it, since it does no discovery. It connects directly to the provided  
> servers. You can set org.elasticsearch.client.transport to TRACE level in  
> your logging configuration (on the client side) to see the failures it has  
> (to connect for example).
> 
> On Thu, Dec 22, 2011 at 11:44 PM, David Loehr [dloehr@servicetask.com](mailto:dloehr@servicetask.com)wrote:
> 
> > I now have the two nodes communicating with each other, but am still  
> > unable to access them through the Java API's TransportClient.
> > 
> > My servers are in Rackspace, and since multicast is disabled there, I  
> > needed to use unicast to get them to discover each other:  
> > discovery:  
> > zen:  
> > ping:  
> > multicast:  
> > enabled: false  
> > unicast:  
> > hosts: "server1:9300,server2:9300"
> > 
> > The second server to start now detects the other as the master, and  
> > through curl, I can see that what I PUT to one, I can GET from the  
> > other.
> > 
> > What settings do I need to use when setting up the TransportClient? Do  
> > I need unicast here? I'm currently doing the following:
> > 
> > ```
> > Settings settings = ImmutableSettings.settingsBuilder()
> > .put("cluster.name", "elasticsearch")
> > .put("client.transport.sniff", true)
> > .put("discovery.zen.ping.multicast.enabled", false)
> > .put("discovery.zen.ping.unicast.enabled", true)
> > .put("discovery.zen.ping.unicast.hosts",
> > 
> > ```
> > 
> > "server1:9300,server2:9300")  
> > .put("discovery.zen.multicast.enabled", false)  
> > .put("discovery.zen.unicast.enabled", true)  
> > .put("discovery.zen.unicast.hosts",  
> > "server1:9300,server2:9300").build();  
> > TransportClient client = new TransportClient(settings)  
> > .addTransportAddress(new  
> > InetSocketTransportAddress("server1", 9300))  
> > .addTransportAddress(new  
> > InetSocketTransportAddress("server2", 9300));  
> > NodesInfoResponse rsp = client.admin().cluster().nodesInfo(new  
> > NodesInfoRequest()).actionGet();  
> > String str = "Cluster:" + rsp.getClusterName() + ". Active  
> > nodes:";  
> > str += rsp.getNodesMap().keySet();  
> > renderText(str);
> > 
> > On Dec 22, 12:27 pm, David Loehr [dlo...@servicetask.com](mailto:dlo...@servicetask.com) wrote:
> > 
> > > Hello,
> > > 
> > > I'm having trouble connecting to elasticsearch through the Java API. I  
> > > have two servers, each running Elasticsearch and my java application  
> > > (Play! Framework). I can connect to elasticsearch using curl on port  
> > > 9200, for example:  
> > > $ curl -XGET server1:9200/\_cluster/health
> > 
> > {"cluster\_name":"elasticsearch","status":"yellow","timed\_out":false,"number  
> > \_of\_nodes":
> > 
> > > 1,"number\_of\_data\_nodes":1,"active\_primary\_shards":5,"active\_shards":  
> > > 5,"relocating\_shards":0,"initializing\_shards":0,"unassigned\_shards":5}
> > > 
> > > But when I try to connect with the Java API on port 9300, I get a  
> > > NoNodeAvailableException. I've opened ports 9200 and 9300 on my  
> > > firewall. The ES log on each server, and the cluster health above,  
> > > seem to indicate that the two instances of Elasticsearch aren't  
> > > connecting to each other. I read in a few other threads that this is  
> > > often caused by mismatched cluster names, but I'm using the default  
> > > value, "elasticsearch".
> > > 
> > > What am I doing wrong?
> > > 
> > > Stack trace:  
> > > play.exceptions.JavaExecutionException: No node available  
> > > at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)  
> > > at Invocation.HTTP Request(Play!)  
> > > Caused by:  
> > > org.elasticsearch.client.transport.NoNodeAvailableException: No node  
> > > available  
> > > at
> > 
> > org.elasticsearch.client.transport.TransportClientNodesService.execute(Tran  
> > sportClientNodesService.java:
> > 
> > > 1. at
> > 
> > org.elasticsearch.client.transport.support.InternalTransportClusterAdminCli  
> > ent.state(InternalTransportClusterAdminClient.java:
> > 
> > > 1. at controllers.Search.index(Search.java:36)
> > > 
> > > /etc/elasticsearch/elasticsearch.yml config file (Elastic search is  
> > > set up as a service, as described athttp://  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elastics)...  
> > > cluster:  
> > > name: elasticsearch  
> > > network:  
> > > host: _eth1:ipv4_
> > > 
> > > Elastic Search logs:  
> > > Server 1:  
> > > [2011-12-22 16:47:25,350][INFO][node] [Fight-  
> > > Man] {0.18.6}[1605]: initializing ...  
> > > [2011-12-22 16:47:25,365][INFO][plugins] [Fight-  
> > > Man] loaded , sites   
> > > [2011-12-22 16:47:28,228][INFO][node] [Fight-  
> > > Man] {0.18.6}[1605]: initialized  
> > > [2011-12-22 16:47:28,229][INFO][node] [Fight-  
> > > Man] {0.18.6}[1605]: starting ...  
> > > [2011-12-22 16:47:28,324][INFO][transport] [Fight-  
> > > Man] bound\_address {inet[/10.182.35.60:9300]}, publish\_address {inet[/  
> > > 10.182.1.2:9300]}  
> > > [2011-12-22 16:47:31,369][INFO][cluster.service] [Fight-  
> > > Man] new\_master [Fight-Man][D\_A18QcATlaFPE28FI5-gg][inet[/  
> > > 10.182.1.2:9300]], reason: zen-disco-join (elected\_as\_master)  
> > > [2011-12-22 16:47:31,444][INFO][discovery] [Fight-  
> > > Man] elasticsearch/D\_A18QcATlaFPE28FI5-gg  
> > > [2011-12-22 16:47:31,678][INFO][http] [Fight-  
> > > Man] bound\_address {inet[/10.182.35.60:9200]}, publish\_address {inet[/  
> > > 10.182.1.2:9200]}  
> > > [2011-12-22 16:47:31,679][INFO][node] [Fight-  
> > > Man] {0.18.6}[1605]: started  
> > > [2011-12-22 16:47:32,393][INFO][gateway] [Fight-  
> > > Man] recovered [1] indices into cluster\_state
> > > 
> > > Server 2:  
> > > [2011-12-22 16:52:10,402][INFO][node] [Jack-in-  
> > > the-Box] {0.18.6}[1799]: initializing ...  
> > > [2011-12-22 16:52:10,411][INFO][plugins] [Jack-in-  
> > > the-Box] loaded , sites   
> > > [2011-12-22 16:52:13,505][INFO][node] [Jack-in-  
> > > the-Box] {0.18.6}[1799]: initialized  
> > > [2011-12-22 16:52:13,507][INFO][node] [Jack-in-  
> > > the-Box] {0.18.6}[1799]: starting ...  
> > > [2011-12-22 16:52:13,659][INFO][transport] [Jack-in-  
> > > the-Box] bound\_address {inet[/10.182.33.113:9300]}, publish\_address  
> > > {inet[/10.182.3.4:9300]}  
> > > [2011-12-22 16:52:16,815][INFO][cluster.service] [Jack-in-  
> > > the-Box] new\_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/  
> > > 10.182.3.4:9300]], reason: zen-disco-join (elected\_as\_master)  
> > > [2011-12-22 16:52:16,857][INFO][discovery] [Jack-in-  
> > > the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw  
> > > [2011-12-22 16:52:16,950][INFO][http] [Jack-in-  
> > > the-Box] bound\_address {inet[/10.182.33.113:9200]}, publish\_address  
> > > {inet[/10.182.3.4:9200]}  
> > > [2011-12-22 16:52:16,953][INFO][node] [Jack-in-  
> > > the-Box] {0.18.6}[1799]: started  
> > > [2011-12-22 16:52:16,967][INFO][gateway] [Jack-in-  
> > > the-Box] recovered [0] indices into cluster\_state
> > > 
> > > My Java code:  
> > > public class Search extends Controller {
> > > 
> > > ```
> > > @Get("/cluster")
> > > public static void index() {
> > > Settings settings = ImmutableSettings.settingsBuilder()
> > > .put("cluster.name", "elasticsearch").build();
> > > TransportClient client = new TransportClient(settings)
> > > .addTransportAddress(new
> > > 
> > > ```
> > > 
> > > InetSocketTransportAddress("10.182.1.2", 9300))  
> > > .addTransportAddress(new  
> > > InetSocketTransportAddress("10.182.3.4", 9300));  
> > > ActionFuture response =  
> > > client.admin().cluster().state(new ClusterStateRequest()); // Throws  
> > > exception  
> > > renderText(response.actionGet().getClusterName().toString());  
> > > }
> > > 
> > > ```
> > > @Get("/cluster/node")
> > > public static void node() {
> > > Node node = nodeBuilder().data(false).node();
> > > Client client = node.client();
> > > ActionFuture<ClusterStateResponse> response =
> > > 
> > > ```
> > > 
> > > client.admin().cluster().state(new ClusterStateRequest());
> > 
> > renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //
> > 
> > > Output is   
> > > }
> > > 
> > > }
> > > 
> > > iptables rules:  
> > > ACCEPT tcp -- server1 anywhere tcp dpt:9200  
> > > ACCEPT tcp -- server2 anywhere tcp dpt:9200  
> > > ACCEPT udp -- server1 anywhere udp dpt:9300  
> > > ACCEPT udp -- server2 anywhere udp dpt:9300  
> > > ACCEPT tcp -- server1 anywhere tcp dpt:9300  
> > > ACCEPT tcp -- server2 anywhere tcp dpt:9300

---

<div class="post-metadata">

**Author:** ![David\_Loehr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_loehr/32/2708_2.png) [@David\_Loehr](https://discuss.elastic.co/u/David_Loehr)\
**Post date:** [December 23, 2011, 1:35pm UTC](https://discuss.elastic.co/t/nonodeavailableexception/6223/5 "2011-12-23T13:35:32Z")

</div>

Thank you! After we turned on TRACE logging, we discovered that we  
were using an outdated elasticsearch jar for the client, 0.17.6, and  
0.18.6 for the standalone nodes. Upgrading to 0.18.6 fixed the issue.

On Dec 22, 6:59 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Also, try and set sniff to false (the default). When sniffing it turned on,  
> it will try to connect to the publish host of each node (its logged on each  
> node when it starts up), which might not be the IP you want to connect  
> through.
> 
> On Fri, Dec 23, 2011 at 1:51 AM, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > Transport client does not need the zen discovery settings to be applied to  
> > it, since it does no discovery. It connects directly to the provided  
> > servers. You can set org.elasticsearch.client.transport to TRACE level in  
> > your logging configuration (on the client side) to see the failures it has  
> > (to connect for example).
> 
> > On Thu, Dec 22, 2011 at 11:44 PM, David Loehr [dlo...@servicetask.com](mailto:dlo...@servicetask.com)wrote:
> 
> > > I now have the two nodes communicating with each other, but am still  
> > > unable to access them through the Java API's TransportClient.
> 
> > > My servers are in Rackspace, and since multicast is disabled there, I  
> > > needed to use unicast to get them to discover each other:  
> > > discovery:  
> > > zen:  
> > > ping:  
> > > multicast:  
> > > enabled: false  
> > > unicast:  
> > > hosts: "server1:9300,server2:9300"
> 
> > > The second server to start now detects the other as the master, and  
> > > through curl, I can see that what I PUT to one, I can GET from the  
> > > other.
> 
> > > What settings do I need to use when setting up the TransportClient? Do  
> > > I need unicast here? I'm currently doing the following:
> 
> > > ```
> > > Settings settings = ImmutableSettings.settingsBuilder()
> > > .put("cluster.name", "elasticsearch")
> > > .put("client.transport.sniff", true)
> > > .put("discovery.zen.ping.multicast.enabled", false)
> > > .put("discovery.zen.ping.unicast.enabled", true)
> > > .put("discovery.zen.ping.unicast.hosts",
> > > 
> > > ```
> > > 
> > > "server1:9300,server2:9300")  
> > > .put("discovery.zen.multicast.enabled", false)  
> > > .put("discovery.zen.unicast.enabled", true)  
> > > .put("discovery.zen.unicast.hosts",  
> > > "server1:9300,server2:9300").build();  
> > > TransportClient client = new TransportClient(settings)  
> > > .addTransportAddress(new  
> > > InetSocketTransportAddress("server1", 9300))  
> > > .addTransportAddress(new  
> > > InetSocketTransportAddress("server2", 9300));  
> > > NodesInfoResponse rsp = client.admin().cluster().nodesInfo(new  
> > > NodesInfoRequest()).actionGet();  
> > > String str = "Cluster:" + rsp.getClusterName() + ". Active  
> > > nodes:";  
> > > str += rsp.getNodesMap().keySet();  
> > > renderText(str);
> 
> > > On Dec 22, 12:27 pm, David Loehr [dlo...@servicetask.com](mailto:dlo...@servicetask.com) wrote:
> > > 
> > > > Hello,
> 
> > > > I'm having trouble connecting to elasticsearch through the Java API. I  
> > > > have two servers, each running Elasticsearch and my java application  
> > > > (Play! Framework). I can connect to elasticsearch using curl on port  
> > > > 9200, for example:  
> > > > $ curl -XGET server1:9200/\_cluster/health
> 
> > > {"cluster\_name":"elasticsearch","status":"yellow","timed\_out":false,"number  
> > > \_of\_nodes":
> > > 
> > > > 1,"number\_of\_data\_nodes":1,"active\_primary\_shards":5,"active\_shards":  
> > > > 5,"relocating\_shards":0,"initializing\_shards":0,"unassigned\_shards":5}
> 
> > > > But when I try to connect with the Java API on port 9300, I get a  
> > > > NoNodeAvailableException. I've opened ports 9200 and 9300 on my  
> > > > firewall. The ES log on each server, and the cluster health above,  
> > > > seem to indicate that the two instances of Elasticsearch aren't  
> > > > connecting to each other. I read in a few other threads that this is  
> > > > often caused by mismatched cluster names, but I'm using the default  
> > > > value, "elasticsearch".
> 
> > > > What am I doing wrong?
> 
> > > > Stack trace:  
> > > > play.exceptions.JavaExecutionException: No node available  
> > > > at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)  
> > > > at Invocation.HTTP Request(Play!)  
> > > > Caused by:  
> > > > org.elasticsearch.client.transport.NoNodeAvailableException: No node  
> > > > available  
> > > > at
> 
> > > org.elasticsearch.client.transport.TransportClientNodesService.execute(Tran  
> > > sportClientNodesService.java:
> > > 
> > > > 1. at
> 
> > > org.elasticsearch.client.transport.support.InternalTransportClusterAdminCli  
> > > ent.state(InternalTransportClusterAdminClient.java:
> > > 
> > > > 1. at controllers.Search.index(Search.java:36)
> 
> > > > /etc/elasticsearch/elasticsearch.yml config file (Elastic search is  
> > > > set up as a service, as described athttp://  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/tutorials/2010/07/02/setting-up-elastics)...  
> > > > cluster:  
> > > > name: elasticsearch  
> > > > network:  
> > > > host: _eth1:ipv4_
> 
> > > > Elastic Search logs:  
> > > > Server 1:  
> > > > [2011-12-22 16:47:25,350][INFO][node] [Fight-  
> > > > Man] {0.18.6}[1605]: initializing ...  
> > > > [2011-12-22 16:47:25,365][INFO][plugins] [Fight-  
> > > > Man] loaded , sites   
> > > > [2011-12-22 16:47:28,228][INFO][node] [Fight-  
> > > > Man] {0.18.6}[1605]: initialized  
> > > > [2011-12-22 16:47:28,229][INFO][node] [Fight-  
> > > > Man] {0.18.6}[1605]: starting ...  
> > > > [2011-12-22 16:47:28,324][INFO][transport] [Fight-  
> > > > Man] bound\_address {inet[/10.182.35.60:9300]}, publish\_address {inet[/  
> > > > 10.182.1.2:9300]}  
> > > > [2011-12-22 16:47:31,369][INFO][cluster.service] [Fight-  
> > > > Man] new\_master [Fight-Man][D\_A18QcATlaFPE28FI5-gg][inet[/  
> > > > 10.182.1.2:9300]], reason: zen-disco-join (elected\_as\_master)  
> > > > [2011-12-22 16:47:31,444][INFO][discovery] [Fight-  
> > > > Man] elasticsearch/D\_A18QcATlaFPE28FI5-gg  
> > > > [2011-12-22 16:47:31,678][INFO][http] [Fight-  
> > > > Man] bound\_address {inet[/10.182.35.60:9200]}, publish\_address {inet[/  
> > > > 10.182.1.2:9200]}  
> > > > [2011-12-22 16:47:31,679][INFO][node] [Fight-  
> > > > Man] {0.18.6}[1605]: started  
> > > > [2011-12-22 16:47:32,393][INFO][gateway] [Fight-  
> > > > Man] recovered [1] indices into cluster\_state
> 
> > > > Server 2:  
> > > > [2011-12-22 16:52:10,402][INFO][node] [Jack-in-  
> > > > the-Box] {0.18.6}[1799]: initializing ...  
> > > > [2011-12-22 16:52:10,411][INFO][plugins] [Jack-in-  
> > > > the-Box] loaded , sites   
> > > > [2011-12-22 16:52:13,505][INFO][node] [Jack-in-  
> > > > the-Box] {0.18.6}[1799]: initialized  
> > > > [2011-12-22 16:52:13,507][INFO][node] [Jack-in-  
> > > > the-Box] {0.18.6}[1799]: starting ...  
> > > > [2011-12-22 16:52:13,659][INFO][transport] [Jack-in-  
> > > > the-Box] bound\_address {inet[/10.182.33.113:9300]}, publish\_address  
> > > > {inet[/10.182.3.4:9300]}  
> > > > [2011-12-22 16:52:16,815][INFO][cluster.service] [Jack-in-  
> > > > the-Box] new\_master [Jack-in-the-Box][tCfshMH-Q1KbsK6eYUTthw][inet[/  
> > > > 10.182.3.4:9300]], reason: zen-disco-join (elected\_as\_master)  
> > > > [2011-12-22 16:52:16,857][INFO][discovery] [Jack-in-  
> > > > the-Box] elasticsearch/tCfshMH-Q1KbsK6eYUTthw  
> > > > [2011-12-22 16:52:16,950][INFO][http] [Jack-in-  
> > > > the-Box] bound\_address {inet[/10.182.33.113:9200]}, publish\_address  
> > > > {inet[/10.182.3.4:9200]}  
> > > > [2011-12-22 16:52:16,953][INFO][node] [Jack-in-  
> > > > the-Box] {0.18.6}[1799]: started  
> > > > [2011-12-22 16:52:16,967][INFO][gateway] [Jack-in-  
> > > > the-Box] recovered [0] indices into cluster\_state
> 
> > > > My Java code:  
> > > > public class Search extends Controller {
> 
> > > > ```
> > > > @Get("/cluster")
> > > > public static void index() {
> > > > Settings settings = ImmutableSettings.settingsBuilder()
> > > > .put("cluster.name", "elasticsearch").build();
> > > > TransportClient client = new TransportClient(settings)
> > > > .addTransportAddress(new
> > > > 
> > > > ```
> > > > 
> > > > InetSocketTransportAddress("10.182.1.2", 9300))  
> > > > .addTransportAddress(new  
> > > > InetSocketTransportAddress("10.182.3.4", 9300));  
> > > > ActionFuture response =  
> > > > client.admin().cluster().state(new ClusterStateRequest()); // Throws  
> > > > exception  
> > > > renderText(response.actionGet().getClusterName().toString());  
> > > > }
> 
> > > > ```
> > > > @Get("/cluster/node")
> > > > public static void node() {
> > > > Node node = nodeBuilder().data(false).node();
> > > > Client client = node.client();
> > > > ActionFuture<ClusterStateResponse> response =
> > > > 
> > > > ```
> > > > 
> > > > client.admin().cluster().state(new ClusterStateRequest());
> 
> > > renderText(response.actionGet().state().getNodes().dataNodes().keySet()); //
> > > 
> > > > Output is   
> > > > }
> 
> > > > }
> 
> > > > iptables rules:  
> > > > ACCEPT tcp -- server1 anywhere tcp dpt:9200  
> > > > ACCEPT tcp -- server2 anywhere tcp dpt:9200  
> > > > ACCEPT udp -- server1 anywhere udp dpt:9300  
> > > > ACCEPT udp -- server2 anywhere udp dpt:9300  
> > > > ACCEPT tcp -- server1 anywhere tcp dpt:9300  
> > > > ACCEPT tcp -- server2 anywhere tcp dpt:9300

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:44am UTC](https://discuss.elastic.co/t/nonodeavailableexception/6223/6 "2017-07-06T03:44:26Z")

</div>


