Elasticsearch 5 Java Client giving "NoNodeAvailableException" Elasticsearch 5 Java Client giving "NoNodeAvailableException" elasticsearch elasticsearch

Elasticsearch 5 Java Client giving "NoNodeAvailableException"


In your elasticsearch.yml configuration file you need to make sure to bind to the correct host and have the following setting:

network.host: 54.175.155.56

Also in your Java code, since you're using the transport client you need to use the port 9300 (for TCP communication) and not 9200, which is meant for HTTP communication (e.g. via curl)

    client = new org.elasticsearch.transport.client.PreBuiltTransportClient(settings)        .addTransportAddress(new org.elasticsearch.common.transport.InetSocketTransportAddress(            InetAddress.getByName("54.175.155.56"), 9300));                                                     ^                                                     |                                                change this


The node to which I was connecting to was only a master node. It had node.ingest and node.data as false. On connecting to a node which had node.ingest as true and removing the client.transport.sniff setting in the Java client, I was able to connect to the ES cluster.


Most Probably the answer of this question is clustername may be different from the elasticsearch.yml, do configure that and in elasticsearch it uses two ports: they are 9200 which provides access through http and 9300 is used for accessing Elasticsearch through the internal transport protocol, which is used by Java Transport Client.