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

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}{}]]

My code :

public Client client(){
TransportClient client = null;
System.out.println("host:"+ host+"port:"+port);
final Settings elasticsearchSettings = Settings.builder()
.put("client.transport.sniff", true)
.put("", 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) {
return client;
public ElasticsearchOperations elasticsearchTemplate() {
return new ElasticsearchTemplate(client());

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

public void setHost(String host) { = host;

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

public String getClusterName() {
    return clusterName;

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


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

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