# None of the configured nodes are available（5.5.0）

**URL:** <https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951>\
**Category:** 中文提问与讨论\
**Created:** [July 28, 2017, 12:14pm UTC](https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951 "2017-07-28T12:14:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![felayman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felayman/32/20791_2.png) [@felayman](https://discuss.elastic.co/u/felayman)\
**Post date:** [July 28, 2017, 12:14pm UTC](https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951/1 "2017-07-28T12:14:45Z")

</div>

在使用官方Elasticsearch5.5.0版本的java客户端来连接启动在本地的ES的时候会出现如下错误:  
`NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{RtE8nzE9RMSz6nsPf28R8w}{localhost}{127.0.0.1:9300}] ] at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347) at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:245) at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59) at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:363) at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:408) at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:397) at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1250) at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.analyze(AbstractClient.java:1647) at org.visualchina.elasticsearch.api.demo.BaseDemo.testConnection(BaseDemo.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) tStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)`  
我的pom.xml文件为:  
`\<?xml version="1.0" encoding="UTF-8"?\>  
  
4.0.0

```
<groupId>com.vcg.community</groupId>
<artifactId>elasticsearch-java-api</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<developers>
    <developer>
        <id>felayman</id>
        <name>felayman</name>
        <email>felayman@gmail.com</email>
    </developer>
</developers>

<properties>
    <elasticsearch.version>5.5.0</elasticsearch.version>
    <spring-version>4.2.8.RELEASE</spring-version>
    <spring-elasticsearch-version>2.0.5.RELEASE</spring-elasticsearch-version>
    <spring-data-elasticsearch-version>3.0.0.BUILD-SNAPSHOT</spring-data-elasticsearch-version>
    <spring-test-version>4.0.2.RELEASE</spring-test-version>
    <fastjson-version>1.2.7</fastjson-version>
    <junit-version>4.10</junit-version>
    <slf4j-version>1.7.5</slf4j-version>
    <ik.version>3.2.8</ik.version>
    <spring-test-version>4.1.6.RELEASE</spring-test-version>
    <dubbo-version>2.5.3</dubbo-version>
    <httpclient-version>4.5.1</httpclient-version>
    <zkclient-version>0.1</zkclient-version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>${fastjson-version}</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>${elasticsearch.version}</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>transport</artifactId>
        <version>${elasticsearch.version}</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-elasticsearch</artifactId>
        <version>${spring-data-elasticsearch-version}</version>
        <exclusions>
            <exclusion>
                <artifactId>elasticsearch</artifactId>
                <groupId>org.elasticsearch</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.wltea.ik-analyzer</groupId>
        <artifactId>ik-analyzer</artifactId>
        <version>${ik.version}</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>spring-libs-snapshot</id>
        <name>Spring Snapshot Repository</name>
        <url>http://repo.spring.io/libs-snapshot</url>
    </repository>
</repositories>

```

`

我的测试代码为：  
`public class BaseDemo {

```
protected TransportClient client;
protected ElasticsearchTemplate elasticsearchTemplate;

@Before
public void setUp() throws Exception {
    client = new PreBuiltTransportClient(Settings.EMPTY)
            .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
    elasticsearchTemplate = new ElasticsearchTemplate(client);
}

@Test
public void testConnection() throws Exception {
    AnalyzeRequest analyzeRequest = new AnalyzeRequest();
    analyzeRequest.text("Sean Archer");
    ActionFuture<AnalyzeResponse> analyzeResponseActionFuture = elasticsearchTemplate.getClient().admin().indices().analyze(analyzeRequest);
    System.out.println(analyzeResponseActionFuture.actionGet().getTokens());
}

```

}`  
我测试了好几个版本,发现5.x版本中有好几个都无法连接,切换成2.x则可以

---

<div class="post-metadata">

**Author:** ![medcl.net](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medcl.net/32/4414_2.png) [@medcl.net](https://discuss.elastic.co/u/medcl.net)\
**Post date:** [August 1, 2017, 2:50am UTC](https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951/2 "2017-08-01T02:50:02Z")

</div>

集群名是默认的么？

---

<div class="post-metadata">

**Author:** ![felayman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felayman/32/20791_2.png) [@felayman](https://discuss.elastic.co/u/felayman)\
**Post date:** [August 2, 2017, 9:06am UTC](https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951/3 "2017-08-02T09:06:32Z")

</div>

@medcl.net 是的 所有配置都是默认的

---

<div class="post-metadata">

**Author:** ![medcl.net](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medcl.net/32/4414_2.png) [@medcl.net](https://discuss.elastic.co/u/medcl.net)\
**Post date:** [August 10, 2017, 1:03am UTC](https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951/4 "2017-08-10T01:03:32Z")

</div>

可以把localhost缓存127.0.0.1试试，另外再netstat看看es监控的是哪个ip呢？

---

<div class="post-metadata">

**Author:** ![felayman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felayman/32/20791_2.png) [@felayman](https://discuss.elastic.co/u/felayman)\
**Post date:** [August 10, 2017, 4:07am UTC](https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951/5 "2017-08-10T04:07:15Z")

</div>

@medcl.net 谢谢你的回答,问题原因找到了,是因为装了x-pack插件后,需要填写x-pack相关的设置,改成下面的方式就可以了.

```auto
 Settings settings = Settings.builder(). put("xpack.security.user", "elastic:changeme").build();
       client = new PreBuiltXPackTransportClient(settings)
               .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
       elasticsearchTemplate = new ElasticsearchTemplate(client);
       final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
       credentialsProvider.setCredentials(AuthScope.ANY,
               new UsernamePasswordCredentials("elastic", "changeme"));
       restClient = RestClient.builder(new HttpHost("localhost",9200,"http"))
               .setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
                   @Override
                   public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
                       return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
                   }
               }).build();

```

---

<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:** [September 7, 2017, 4:07am UTC](https://discuss.elastic.co/t/none-of-the-configured-nodes-are-available-5-5-0/94951/6 "2017-09-07T04:07:25Z")

</div>

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