# Error client.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));

**URL:** https://discuss.elastic.co/t/error-client-addtransportaddress-new-transportaddress-inetaddress-getbyname-localhost-9300/239098
**Category:** Elasticsearch
**Created:** [June 29, 2020, 11:11am UTC](https://discuss.elastic.co/t/error-client-addtransportaddress-new-transportaddress-inetaddress-getbyname-localhost-9300/239098 "2020-06-29T11:11:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Najib\_Ghlissi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/najib_ghlissi/32/71289_2.png) [@Najib\_Ghlissi](https://discuss.elastic.co/u/Najib_Ghlissi)
#### Post date: [June 29, 2020, 11:11am UTC](https://discuss.elastic.co/t/error-client-addtransportaddress-new-transportaddress-inetaddress-getbyname-localhost-9300/239098/1 "2020-06-29T11:11:29Z")

</div>

hi All developers  
i have i error in my projetct  
**Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{zSavWRA4QBGzdYdox-h2Aw}{localhost}{127.0.0.1:9300}]]  
att**

My code :

> @Bean  
> public Client client(){  
> TransportClient client = null;  
> try{  
> System.out.println("host:"+ host+"port:"+port);  
> final Settings elasticsearchSettings = Settings.builder()  
> .put("client.transport.sniff", true)  
> .put("cluster.name", clusterName).build();  
> /_client = new PreBuiltTransportClient(Settings.EMPTY)  
> .addTransportAddress(new TransportAddress(InetAddress.getByName(host), port));_/  
> client = new PreBuiltTransportClient(Settings.EMPTY);  
> client.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));  
> } catch (UnknownHostException e) {  
> e.printStackTrace();  
> }  
> return client;  
> }  
> @Bean  
> public ElasticsearchOperations elasticsearchTemplate() {  
> return new ElasticsearchTemplate(client());  
> }

```
public String getHost() {
    return host;
}
public int getPort() {
    return port;
}

public void setHost(String host) {
    this.host = host;
}

public void setPort(int port) {
    this.port = port;
}

public String getClusterName() {
    return clusterName;
}

public void setClusterName(String clusterName) {
this.clusterName = clusterName;

```

}

---

<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: [June 29, 2020, 7:52pm UTC](https://discuss.elastic.co/t/error-client-addtransportaddress-new-transportaddress-inetaddress-getbyname-localhost-9300/239098/2 "2020-06-29T19:52:24Z")

</div>

Don't use the TransportClient. It has been deprecated and will be removed. Use the rest client instead.

---

<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: [July 27, 2020, 7:52pm UTC](https://discuss.elastic.co/t/error-client-addtransportaddress-new-transportaddress-inetaddress-getbyname-localhost-9300/239098/3 "2020-07-27T19:52:39Z")

</div>

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