【问题标题】:connection error while using the python elasticsearch使用 python elasticsearch 时出现连接错误
【发布时间】:2020-02-11 22:53:15
【问题描述】:

我尝试执行下面的python代码

from datetime import datetime
from elasticsearch import Elasticsearch
es = Elasticsearch()
es.indices.create(index='my-index', ignore=400)

最后一条语句通过下面的连接出错。

ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 
0x0000020DC5EEF6D8>: Failed to establish a new connection: [WinError 10061] No 
connection could be made because the target machine actively refused it) caused 
by: NewConnectionError(<urllib3.connection.HTTPConnection object at 
0x0000020DC5EEF6D8>: Failed to establish a new connection: [WinError 10061] No 
connection could be made because the target machine actively refused it)

【问题讨论】:

  • 请明确说明问题所在以及您要解决的问题。
  • 你访问 Elasticsearch elasticsearch:9200?
  • 我有该问题及其解决方案的历史用户描述。我想在出现新问题时提供解决方案建议。为此,当我得到新的问题描述时,我想对历史问题描述进行弹性搜索,并为当前问题提供快速解决方案。

标签: python elasticsearch


【解决方案1】:

看来您已经安装了唯一的 elasticsearch 客户端库,而没有在计算机中安装实际的 Elasticsearch。 因此首先按如下方式安装 Elasticsearch。 Download and Install

在你下载了一个 zip 文件(如果你使用的是 windows)之后,进入类似c:\elasticsearch-7.5.2的文件中

转到C:\elasticsearch-7.5.2\bin 之类的路径并运行elasticsearch.bat

然后到你的浏览器运行http://localhost:9200/,你应该得到类似的响应,这意味着你的弹性实例正在运行,所以你可以继续

es.indices.create(index='my-index', ignore=400)

如果您想要自定义实例,可以阅读教程Here

如果您在使用 python elasticsearch 时遇到连接错误,则已经回答Here

【讨论】:

    猜你喜欢
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-21
    • 1970-01-01
    • 2019-06-26
    • 1970-01-01
    相关资源
    最近更新 更多