简体   繁体   English

弹性搜索:通过RestHighLevelClient连接时的java.net.ConnectException

[英]Elastic search: java.net.ConnectException when connecting via RestHighLevelClient

I am able to access the ElasticSearch via http://127.0.0.1:9200 , however when trying to connect from the same machine via RestHighLevelClient I get the java.net.ConnectException: Connection refused. 我可以通过http://127.0.0.1:9200访问ElasticSearch,但是当尝试通过RestHighLevelClient从同一台计算机连接时,我得到了java.net.ConnectException:连接被拒绝。

 try { final BulkResponse response=this.restHighLevelClient.bulk(bulkRequest); } catch (final IOException exn) { LOG.error("Bulk insert failed", exn); } 

The configuration class for Elastic search client is like below. Elastic search客户端的配置类如下所示。

 @Bean public RestHighLevelClient restClient() { return new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", "9200", "http"))); } 

I have retained the default settings in elastic-search.yml file and debugged to be sure that host and port are correct. 我已将默认设置保留在elastic-search.yml文件中,并进行了调试以确保主机和端口正确。 Any ideas please? 有什么想法吗?

我有同样的问题,但是我的问题是我错误地连接到错误的主机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM