# Trying to connect to Elasticsearch with java client on port 9222

**URL:** <https://discuss.elastic.co/t/trying-to-connect-to-elasticsearch-with-java-client-on-port-9222/99990>\
**Category:** Elasticsearch\
**Created:** [September 11, 2017, 3:22am UTC](https://discuss.elastic.co/t/trying-to-connect-to-elasticsearch-with-java-client-on-port-9222/99990 "2017-09-11T03:22:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntonQUT](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@AntonQUT](https://discuss.elastic.co/u/AntonQUT)\
**Post date:** [September 11, 2017, 3:22am UTC](https://discuss.elastic.co/t/trying-to-connect-to-elasticsearch-with-java-client-on-port-9222/99990/1 "2017-09-11T03:22:40Z")

</div>

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", 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}{127.0.0.1:9222}]

But ES is operational on that port:

curl '[http://localhost:9222/?pretty](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?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 11, 2017, 4:01am UTC](https://discuss.elastic.co/t/trying-to-connect-to-elasticsearch-with-java-client-on-port-9222/99990/2 "2017-09-11T04:01:01Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![AntonQUT](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@AntonQUT](https://discuss.elastic.co/u/AntonQUT)\
**Post date:** [September 11, 2017, 4:31am UTC](https://discuss.elastic.co/t/trying-to-connect-to-elasticsearch-with-java-client-on-port-9222/99990/3 "2017-09-11T04:31:19Z")

</div>

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.

Thanks

---

<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:** [October 9, 2017, 4:31am UTC](https://discuss.elastic.co/t/trying-to-connect-to-elasticsearch-with-java-client-on-port-9222/99990/4 "2017-10-09T04:31:30Z")

</div>

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