# No Node Available Exception ES-5.0.2

**URL:** <https://discuss.elastic.co/t/no-node-available-exception-es-5-0-2/73640>\
**Category:** Elasticsearch\
**Created:** [February 2, 2017, 7:26am UTC](https://discuss.elastic.co/t/no-node-available-exception-es-5-0-2/73640 "2017-02-02T07:26:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zelmm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zelmm/32/15134_2.png) [@Zelmm](https://discuss.elastic.co/u/Zelmm)\
**Post date:** [February 2, 2017, 7:26am UTC](https://discuss.elastic.co/t/no-node-available-exception-es-5-0-2/73640/1 "2017-02-02T07:26:10Z")

</div>

Hi all.  
First for all, i'm sorry for my english.  
I have a problem with Java API Transport Client. I have one master node and three data nodes.  
I try to connect to my cluster with Transport Client and then i response "NoNodeAvailableException[None of the configured nodes are available".

That is my code of client:

```
import java.net.InetAddress;
import java.net.UnknownHostException;

import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;

public class Main {
	private static String[] hosts = new String[] {
			"XX.XX.X.XXX"
			,"XX.XX.X.XXX"
			,"XX.XX.X.XXX"
			,"XX.XX.X.XXX"			
			};

	private static final Settings settings = Settings.builder()
			.put("cluster.name", "myCluster")
			.put("client.transport.sniff", true)
			.put("transport.tcp.port", 9300)
			.put("xpack.security.user", "transport_client_user:changeme")
			.build();
	private static final String index = "myIndex";
	private static final String type = "myType";
	private static TransportClient client;
	
	
	public static void main(String[] args) throws UnknownHostException {
		
		InetSocketTransportAddress[] ista = new InetSocketTransportAddress[hosts.length]; 
    	
    	for (int i = 0; i < hosts.length; i++) {
		ista[i] = new InetSocketTransportAddress(InetAddress.getByName(hosts[i]), 9300);
	}

    	client = new PreBuiltXPackTransportClient(settings).addTransportAddresses(ista);    	
    	
    	SearchRequestBuilder rb = client
    			.prepareSearch(index)
				.setTypes(type)
				.setSearchType(SearchType.DEFAULT)
			    .setQuery(QueryBuilders.termQuery("_id", 3524598));
		
    	
		SearchResponse sResponse = rb.get();
		System.out.println(sResponse.toString());
	}
}

```

Port for transport client - 9300, all my nodes communicate under this port. I saw a lot like my question, and i trying to follow the advice contained in them. But i have the same exception.

If need more information or any files or settings of my Elastic - i'm ready to answer.

---

<div class="post-metadata">

**Author:** ![Zelmm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zelmm/32/15134_2.png) [@Zelmm](https://discuss.elastic.co/u/Zelmm)\
**Post date:** [February 2, 2017, 10:12am UTC](https://discuss.elastic.co/t/no-node-available-exception-es-5-0-2/73640/2 "2017-02-02T10:12:18Z")

</div>

If it is important this is content of elasticsearch.yml

```
cluster.name: myCluster
node.name: elastic-0

path.data: /var/db/elasticsearch
path.logs: /var/log/elasticsearch
path.scripts: /usr/local/libexec/elasticsearch

network.host: _vmx0_

node.master: true 
node.data: false 
node.ingest: false 

node.attr.rack_id: rack_one
cluster.routing.allocation.awareness.attributes: rack_id

discovery.zen.minimum_master_nodes: 3
discovery.zen.ping.unicast.hosts: ["XX.XX.X.XXX","XX.XX.X.XXX","XX.XX.X.XXX","XX.XX.X.XXX","XX.XX.X.XXX"]

bootstrap.memory_lock: false

xpack.monitoring.exporters:
  id1:
    type: http
    host: ["XX.XX.X.XXX:9200"] 
    auth.username: remote_monitor 
    auth.password: changeme
```

---

<div class="post-metadata">

**Author:** ![Zelmm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zelmm/32/15134_2.png) [@Zelmm](https://discuss.elastic.co/u/Zelmm)\
**Post date:** [February 6, 2017, 11:17am UTC](https://discuss.elastic.co/t/no-node-available-exception-es-5-0-2/73640/3 "2017-02-06T11:17:52Z")

</div>

I found the reason for which i received "NoNodeAvailableException".

The reason is transport\_client's role does not grant permission to view the data in all indices on default.  
And i will to built my role for the access to data in indices.

Link: https://www.elastic.co/guide/en/x-pack/5.0/built-in-roles.html

---

<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:** [March 6, 2017, 11:17am UTC](https://discuss.elastic.co/t/no-node-available-exception-es-5-0-2/73640/4 "2017-03-06T11:17:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
