Rest High level client initialization, What are the ports needed

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

Link to High level client

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 ?

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.

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

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