None of the configured nodes are available: [{#transport#-1}{...}{127.0.0.1}{127.0.0.1:9300}]

I use ElasticSearch v5.0 in java application and create index. But the 9300 port can't work.

Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{wT9q99-KSTObzOpHJGj5bA}{127.0.0.1}{127.0.0.1:9300}]]


This is java code:

public static void main(String[] args) {
        Settings settings = Settings.builder()
                .put("client.transport.sniff", true)
                .put("cluster.name", "clusterTest")
                .build();
        client = new PreBuiltTransportClient(settings)
                .addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
        List<String> jsonList = DataFactory.getInitJsonData();
        String indexname = "esIndex";
        String type = "esType";

        ElasticApp app = new ElasticApp();
        app.createIndex(indexname, type, jsonList);
    }

    private void createIndex(String indexname, String type, List<String> jsonList){
        try {
            IndexRequestBuilder requestBuilder = client.prepareIndex(indexname, type, "1").setCreate(true);

            for (int i=0;i<jsonList.size();i++){
                requestBuilder.setSource(XContentFactory.jsonBuilder()
                        .startObject()
                        .field(jsonList.get(i))
                        .endObject()

                ).execute().actionGet();
            }
            System.out.print("Create Index Success");
        } catch (IOException e) {
            e.printStackTrace();
            System.out.print("Fdiled");
        }
    }
1 Like

There are two ports used by Elasticsearch. The port 9200 provides access through http (e.g. your browser). The port 9300 is used for accessing Elasticsearch through the internal transport protocol, which is used by the Java transport client.

Can you check whether the cluster.name you've used in your java example corresponds to the cluster name you've used in your Elasticsearch cluster configuration (elasticsearch.yml)?

5 Likes

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