AWS elastic search error “[Errno 8] nodename nor servname provided, or not known.”

帅比萌擦擦* 提交于 2019-12-21 03:58:27

问题


I created one AWS elasticsearch instance. I want to access it using a python script. I specified my AWS configuration (access key, secret key, region). I am using below code to access the AWS ES instance:

from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth

AWS_ACCESS_KEY = '**************'
AWS_SECRET_KEY = '*****************'
region = 'us-east-1'
service = 'es'

awsauth = AWS4Auth(AWS_ACCESS_KEY, AWS_SECRET_KEY, region, service)

host = 'https://kbckjsdkcdn.us-east-1.es.amazonaws.com' # For example, my-test-domain.us-east-1.es.amazonaws.com

es = Elasticsearch(
    hosts = [{'host': host, 'port': 443}],
    http_auth = awsauth,
    use_ssl = True,
    verify_certs = True,
    connection_class = RequestsHttpConnection
)

print es.info()

When I am running the above code, I am getting following error:

elasticsearch.exceptions.ConnectionError:  ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-opendata-2xd6pwilq5sv4ahomcuaiyxmqe.us-east-1.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10ee72310>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))) caused by: ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-opendata-2xd6pwilq5sv4ahomcuaiyxmqe.us-east-1.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10ee72310>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',)))

How can I resolve this error?

Thanks


回答1:


Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known seems to indicate that the elasticsearch client is not able to resolve the hostname. It could possibly be because you include the protocol https:// specified in the host.

Change that line to host = 'kbckjsdkcdn.us-east-1.es.amazonaws.com' to see if it works. Also the example comment you have there, seems to indicate that the protocol should not be included in the host variable.



来源:https://stackoverflow.com/questions/48275759/aws-elastic-search-error-errno-8-nodename-nor-servname-provided-or-not-known

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!