Max retries exceeded with (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object [Errno -5] No address associated with hostname',))
Asked Answered
H

0

8

I have build a flask application. This application makes an API call to a graphql server which has a url like "http://xyz:8080/graphql".

The application is containerized in docker container and runs on docker compose.

This exterenal graphql server is accessible from the chrome browser and api tools . but when the container calls the server url it gives an error like this.

**HTTPConnectionPool(host='xyz', port=8080): Max retries exceeded with url: /graphql (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f21777
f0c18>: Failed to establish a new connection: [Errno -5] No address associated with hostname',))**

the url is binded with a DNS and IP address is there as well. I dont have an IP address of the server and just the DNS i.e "xyz" any one faced this kind of issue? below is the class written to connect to graphql in application.

  import requests

class GraphQL:
  def graphql(self, query, variables = {}, headers = None):
    url = 'http://xyz:8080/graphql'
    response = requests.post(
        url = url,
        json = {'query': query, 'variables': variables},
        headers = headers
    )
    return response
Hellman answered 6/4, 2020 at 8:14 Comment(4)
out of curiosity are you able to do a dns look up of the domain name in DNS? if you try using just the ip instead of domain name does it work?Unpaidfor
are your flask app and graphql server on the same docker network? (docker network inspect $NETWORKNAME)Melliemelliferous
graphql is hosted on a diferent server. its a production server. could not look up the DNS name ,Hellman
But was able to do it with IP addressHellman

© 2022 - 2024 — McMap. All rights reserved.