# Java API connect the ES

**URL:** https://discuss.elastic.co/t/java-api-connect-the-es/68814
**Category:** Elasticsearch
**Created:** [December 13, 2016, 5:02am UTC](https://discuss.elastic.co/t/java-api-connect-the-es/68814 "2016-12-13T05:02:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![lester015](https://avatars.discourse-cdn.com/v4/letter/l/cc9497/32.png) [@lester015](https://discuss.elastic.co/u/lester015)
#### Post date: [December 13, 2016, 5:02am UTC](https://discuss.elastic.co/t/java-api-connect-the-es/68814/1 "2016-12-13T05:02:33Z")

</div>

Dear team,  
recently, I using the java API connect the ES 2.3.3 client which has installed the shield. the error as flows:

```
     Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available:

```

BTW, I cannot found the user and password setting in elasticsearch.yml. here was my java code:

public static Client getEsConnection()  
{  
String clusterName = "elasticsearch";

```
    Settings settings = Settings.settingsBuilder()
            .put("cluster.name", clusterName)
            .build();
    Client client = null;
    try {
        client = TransportClient.builder().settings(settings).build()
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("10.xx.xx.xx"), 9300))
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("10.xx.xx.xx"), 9300))
                .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("10.xx.xx.xx"), 9300));

    } catch (UnknownHostException e) {
        e.printStackTrace();
    }

    return client;

}

```

Levi,  
thanks

---

<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: [December 13, 2016, 6:05am UTC](https://discuss.elastic.co/t/java-api-connect-the-es/68814/2 "2016-12-13T06:05:03Z")

</div>

Here we go: [https://www.elastic.co/guide/en/shield/current/\_using\_elasticsearch\_java\_clients\_with\_shield.html](https://www.elastic.co/guide/en/shield/current/_using_elasticsearch_java_clients_with_shield.html)

---

<div class="post-metadata">

### Author: ![lester015](https://avatars.discourse-cdn.com/v4/letter/l/cc9497/32.png) [@lester015](https://discuss.elastic.co/u/lester015)
#### Post date: [December 13, 2016, 7:34am UTC](https://discuss.elastic.co/t/java-api-connect-the-es/68814/3 "2016-12-13T07:34:09Z")

</div>

Thanks for quick response!

---

<div class="post-metadata">

### Author: ![lester015](https://avatars.discourse-cdn.com/v4/letter/l/cc9497/32.png) [@lester015](https://discuss.elastic.co/u/lester015)
#### Post date: [December 14, 2016, 3:43am UTC](https://discuss.elastic.co/t/java-api-connect-the-es/68814/4 "2016-12-14T03:43:41Z")

</div>

Thanks for dadoonet , I resolve it fallowing the url!

---

<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: [January 11, 2017, 3:44am UTC](https://discuss.elastic.co/t/java-api-connect-the-es/68814/5 "2017-01-11T03:44:11Z")

</div>

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