NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{DzxzK0iPRpWhbsQrG1XL-Q}{localhost}{127.0.0.1:9200}]]

I am facing this error while implementing elastic search in spring boot.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loaders': Invocation of init method failed; nested exception is NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{FzaWEy4gQTeGXw04FAe5HQ}{127.0.0.1}{127.0.0.1:9200}]]

Here is the command im running

docker run -d -p 9200:9200 --name elasticsearch_test docker.elastic.co/elasticsearch/elasticsearch:6.5.4 elasticsearch -Enetwork.publish_host="localhost" -Etransport.publish_port="9200"

Here is node Log

{
"_nodes": {
    "total": 1,
    "successful": 1,
    "failed": 0
},
"cluster_name": "docker-cluster",
"nodes": {
    "-R2MlL29RdOzYYiAzKkrBQ": {
        "name": "-R2MlL2",
        "transport_address": "127.0.0.1:9200",
        "host": "localhost",
        "ip": "127.0.0.1",
        "version": "6.5.4",
        "build_flavor": "default",
        "build_type": "tar",
        "build_hash": "d2ef93d",
        "roles": [
            "master",
            "data",
            "ingest"
        ],
        "attributes": {
            "ml.machine_memory": "2076532736",
            "xpack.installed": "true",
            "ml.max_open_jobs": "20",
            "ml.enabled": "true"
        },
        "http": {
            "bound_address": [
                "0.0.0.0:9200"
            ],
            "publish_address": "127.0.0.1:9200",
            "max_content_length_in_bytes": 104857600
        }
    }
}

}

Here is my Configurations code

public TransportClient client() throws UnknownHostException{
    final Settings esSettings = Settings.builder().put("cluster.name", "docker-cluster").build();
    client = new PreBuiltTransportClient(esSettings);
    client.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), 9200));

    return client;


}

And here is the Error point

public void loadAll() throws UnknownHostException {
    TransportClient client = esconf.client();
    ElasticsearchTemplate esTemplate = new ElasticsearchTemplate(client);
    esTemplate.createIndex("testindex");
}

Error is at the point where im creating index.

I have been through alot of links but no help.
Any help will be appreciated. Thanks

Why did you change the transport port. Keep the default one to 9300 and expose it from docker.

Thanks for the reply David.
I have tried on 9300 aswell but had no luck with it. Here is my other command with 9300

docker run -d -p 9200:9200 --name elasticsearch6 docker.elastic.co/elasticsearch/elasticsearch:6.5.4 elasticsearch -Enetwork.publish_host="localhost" -Etransport.publish_port="9300"

transport port is default 9300 while use TransportClient

Fanfan, Yes I have tried 9300 aswell in transport client

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY);
    client.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));

Try:

docker run -d -p 9200:9200 -p 9300:9300 --name elasticsearch6 docker.elastic.co/elasticsearch/elasticsearch:6.5.4 elasticsearch"

David,
I ran your command but unfortunately still getting the same error. Also my Node log has changes its IP now. Here is the updated node log

{
"_nodes": {
    "total": 1,
    "successful": 1,
    "failed": 0
},
"cluster_name": "docker-cluster",
"nodes": {
    "FwtsGvITR5q9-3hHnfu8yA": {
        "name": "FwtsGvI",
        "transport_address": "172.17.0.2:9300",
        "host": "172.17.0.2",
        "ip": "172.17.0.2",
        "version": "6.5.4",
        "build_flavor": "default",
        "build_type": "tar",
        "build_hash": "d2ef93d",
        "roles": [
            "master",
            "data",
            "ingest"
        ],
        "attributes": {
            "ml.machine_memory": "2076532736",
            "xpack.installed": "true",
            "ml.max_open_jobs": "20",
            "ml.enabled": "true"
        },
        "http": {
            "bound_address": [
                "0.0.0.0:9200"
            ],
            "publish_address": "172.17.0.2:9200",
            "max_content_length_in_bytes": 104857600
        }
    }
}

}

So i Updated my configurations to

client = new PreBuiltTransportClient(Settings.EMPTY);
    client.addTransportAddress(new TransportAddress(InetAddress.getByName("172.17.0.2"), 9300));

Can you try:

client = new PreBuiltTransportClient(Settings.EMPTY);
    client.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));

Had no luck with "localhost" aswell. Here is the error log

2019-01-18 16:19:00.015  WARN 18860 --- [           main] o.e.c.t.TransportClientNodesService      : node {#transport#-1}{9Rg1pf0mQ9K-g4ItyTrK7A}{localhost}{127.0.0.1:9300} not part of the cluster Cluster [elasticsearch], ignoring...
2019-01-18 16:19:00.017  WARN 18860 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loaders': Invocation of init method failed; nested exception is NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{9Rg1pf0mQ9K-g4ItyTrK7A}{localhost}{127.0.0.1:9300}]]

Much better though... not part of the cluster Cluster [elasticsearch]

As your cluster name is docker-cluster you can not use Settings.EMPTY but

client = new PreBuiltTransportClient(Settings.builder().put("cluster.name", "docker-cluster").build());

Thanks for the help Sir.

You're welcome.
I want to add that you should use the rest client instead.

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