I am trying to connect to an ElasticSearch server using the Java API. I using elasticsearch service to start/stop and elasticsearch head for visualising the cluster. The clu
In case anybody else stumbles on this thread, I found out another reason you could receive this error is because the cluster_name has been changed to something other than the default.
To see your current cluser_name:
curl -XGET localhost:9200/_cluster/nodes?pretty=true
Use code similar to what OP has above:
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "test").build();
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
Source: http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html