# Set cluster name when creating connection | ES 8.2.3

**URL:** <https://discuss.elastic.co/t/set-cluster-name-when-creating-connection-es-8-2-3/310139>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [July 20, 2022, 12:10pm UTC](https://discuss.elastic.co/t/set-cluster-name-when-creating-connection-es-8-2-3/310139 "2022-07-20T12:10:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akshat\_Gupta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akshat_gupta/32/108567_2.png) [@Akshat\_Gupta](https://discuss.elastic.co/u/Akshat_Gupta)\
**Post date:** [July 20, 2022, 12:10pm UTC](https://discuss.elastic.co/t/set-cluster-name-when-creating-connection-es-8-2-3/310139/1 "2022-07-20T12:10:07Z")

</div>

How to set cluster name in new ES 8.2.3 java API ?

Earlier I was using:

```auto
private Client client = new PreBuiltTransportClient(Settings.builder().put("cluster.name", esClusterName).build()).addTransportAddress(new TransportAddress(InetAddress.getByName(elasticIp), elasticPort));

```

How it can be done now?  
Till now reached:

```auto
    // Create the low-level client
    RestClient restClient = RestClient.builder(new HttpHost(elasticIp, elasticPort, "https")).build();

    // Create the transport with a Jackson mapper
    ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());

    // And create the API client
    client = new ElasticsearchClient(transport);

```

---

<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 17, 2022, 12:10pm UTC](https://discuss.elastic.co/t/set-cluster-name-when-creating-connection-es-8-2-3/310139/2 "2022-08-17T12:10:49Z")

</div>

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