# Rest High level client initialization, What are the ports needed

**URL:** https://discuss.elastic.co/t/rest-high-level-client-initialization-what-are-the-ports-needed/140033
**Category:** Elasticsearch
**Created:** [July 14, 2018, 2:58pm UTC](https://discuss.elastic.co/t/rest-high-level-client-initialization-what-are-the-ports-needed/140033 "2018-07-14T14:58:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![varun1992](https://avatars.discourse-cdn.com/v4/letter/v/3da27b/32.png) [@varun1992](https://discuss.elastic.co/u/varun1992)
#### Post date: [July 14, 2018, 2:58pm UTC](https://discuss.elastic.co/t/rest-high-level-client-initialization-what-are-the-ports-needed/140033/1 "2018-07-14T14:58:57Z")

</div>

```
RestHighLevelClient client = new RestHighLevelClient(
        RestClient.builder(
                new HttpHost("localhost", 9200, "http"),
                new HttpHost("localhost", 9201, "http")));

```

[Link to High level client](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-getting-started-initialization.html)

What is the use of 9201 port ? what are the ports used by elasticsearch by default. I read elastic using 9300 also. What are the uses of each of it ?

---

<div class="post-metadata">

### Author: ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)
#### Post date: [July 16, 2018, 1:37am UTC](https://discuss.elastic.co/t/rest-high-level-client-initialization-what-are-the-ports-needed/140033/2 "2018-07-16T01:37:59Z")

</div>

> What is the use of 9201 port

It's just an example to show connecting to multiple different ports. If you run 2 elasticsearch nodes on your local machine one of them will listen on `9200` and the other will listen on `9201`.

> [@varun1992](#):
>
> what are the ports used by elasticsearch by default

By default, Elasticsearch opens 2 ports on each node.  
`9200` is the HTTP (Rest) port  
`9300` is the transport (node-to-node communictation) port.

_By default_ if those ports are already in use, it will try to use the next available port (`9201` or `9301`).

You can configure those port numbers with the following settings.

- `http.port`
- `transport.tcp.port`

---

<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: [August 13, 2018, 1:38am UTC](https://discuss.elastic.co/t/rest-high-level-client-initialization-what-are-the-ports-needed/140033/3 "2018-08-13T01:38:00Z")

</div>

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