elasticsearch`无法建立连接,因为目标机器在使用密码auth后主动拒绝它`

elasticsearch `No connection could be made because the target machine actively refused it` after using password auth

我正在尝试使用 python elasticsearch 库连接到我的 elasticsearch 实例:

es = Elasticsearch(HOST="https://elastic:password@3392047428db45a0b0e41659542.us-central1.gcp.cloud.es.io",PORT=9243)
es = Elasticsearch()

但我一直收到错误消息:

elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x000002BD624E6208>: 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 0x000002BD624E6208>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it)

我也试过,但遇到同样的错误:

es = Elasticsearch(['3392047428db45a0b0e41659542.us-central1.gcp.cloud.es.io'], http_auth=('elastic', 'password'))

如果我获取 URL 并手动输入 usernamepassword,我就可以连接。 请帮助我了解导致此错误的可能原因...提前致谢:)

从 elasticsearch 导入 Elasticsearch

es = Elasticsearch(['https://test-ced76a.es.us-centrdadsal1.gcp.cloud.es.io'],http_auth=('elastic', 'password'),scheme="https",port=9243,)

es.indices.create(指数='my-index')