Trying to connect to Elasticsearch with java client on port 9222

I am running Elasticsearch out of port 9222, not 9200, but I have been unable to connect to it from my Java client program.

I changed my connection code to:

			   Settings settings = Settings.builder()
			        .put("", CLUSTER_NAME).build();
		   TransportClient client = new PreBuiltTransportClient(settings)
			        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), ES_PORT));


where ES_Port is 9222,
But it continues to fail with

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{DEI0dsf7Qdy0N_avSqKGfw}{localhost}{}]

But ES is operational on that port:

curl 'http://localhost:9222/?pretty'
"name" : "4FTDLkm",
"cluster_name" : "anton-expt1",
"cluster_uuid" : "BuuMEWMBQQCL915jpWc7Bg",
"version" : {
"number" : "5.3.2",
"build_hash" : "3068195",
"build_date" : "2017-04-24T16:15:59.481Z",
"build_snapshot" : false,
"lucene_version" : "6.4.2"
"tagline" : "You Know, for Search"

How can I get the api client to access the ES instance on that port?

I suppose that 9222 is the REST port not the Transport one.

Either use the REST client (preferred) or use the right transport port (9300 by default)

Hi David,
I have worked it out - I have added the following line to the .yml config file:
transport.tcp.port: 9302

and matched this in the connection. It is now connecting to my instance of Elasticsearch rather than the other one that is used 9300.


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