0

I have setup the elasticsearch domain in AWS Elasticsearch Service. It has endpoint like "https://search-testelasticseach-xxxxxxxxxxxxxxxxxxx.us-east-2.es.amazonaws.com". I am trying to connect the AWS Elasticsearch Domain endpoint using IAM users after adding policies in that elasticsearch domain.

Error says

"Max retries exceeded with url: //search-testelasticseach-XXXXXXXXXXXXXXX.us-east-2.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x105111d68>: 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-testelasticseach-pkpbravqd4djbi3kjtihsra5ma.us-east-2.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x105111d68>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')))"

Code Snippet:

from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
YOUR_ACCESS_KEY = "XXX"
YOUR_SECRET_KEY = "XXXX"
REGION = "us-east-2"
host = 'https://search-testelasticseach-XXX.us-east-2.es.amazonaws.com'
awsauth = AWS4Auth(YOUR_ACCESS_KEY, YOUR_SECRET_KEY, REGION, 'es')

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


print(es.info())
FHTMitchell
  • 11,793
  • 2
  • 35
  • 47
sangeeth kumar
  • 319
  • 2
  • 7
  • 23
  • 3
    Possible duplicate of [AWS elastic search error "\[Errno 8\] nodename nor servname provided, or not known."](https://stackoverflow.com/questions/48275759/aws-elastic-search-error-errno-8-nodename-nor-servname-provided-or-not-known) -- you need to remove the 'https://' from the host name. – i alarmed alien Jul 23 '18 at 10:30
  • Thank you. It helps me. Once i got a connection object. I can able to search data using es.search(index="index-test"). If i tried to add any query body to the search it returns "Undecodable raw error response from server: Expecting value: line 2 column 1 (char 1)" – sangeeth kumar Jul 23 '18 at 11:37
  • that is a separate problem -- check the API docs to make sure that you have formatted your query correctly. – i alarmed alien Jul 23 '18 at 11:39
  • just remove https:// from starts of your host – mujad Feb 07 '21 at 17:13

0 Answers0