2
import requests

url = 'http://ES_search_demo.com/document/record/_search?pretty=true'
data = '{"query":{"bool":{"must":[{"text":{"record.document":"SOME_JOURNAL"}},{"text":{"record.articleTitle":"farmers"}}],"must_not":[],"should":[]}},"from":0,"size":50,"sort":[],"facets":{}}'
response = requests.get(url, data=data)

when i run this code i get this error

    Traceback (most recent call last):
  File "simpleclient.py", line 6, in <module>
    response = requests.get(url, data=data)
  File "/home/ryan/local/lib/python2.7/site-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/home/ryan/local/lib/python2.7/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/ryan/local/lib/python2.7/site-packages/requests/sessions.py", line 471, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/ryan/local/lib/python2.7/site-packages/requests/sessions.py", line 581, in send
    r = adapter.send(request, **kwargs)
  File "/home/ryan/local/lib/python2.7/site-packages/requests/adapters.py", line 481, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='es_search_demo.com', port=80): Max retries exceeded with url: /document/record/_search?pretty=true (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f544af9a5d0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
karthikr
  • 97,368
  • 26
  • 197
  • 188
mohamed desouky
  • 39
  • 1
  • 2
  • 4

2 Answers2

8

NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f8f95d196d0>: Failed to establish a new connection: [Errno -5] No address associated with hostname',))

It means the Domain Name Server (DNS) that your computer is connecting to does not know about the given host.

However there is a valid IP address with the domain name if we check for it.

$ nslookup mmsdemo.cloudapp.net
(...)

Non-authoritative answer:
Name:   mmsdemo.cloudapp.net
Address: 40.113.108.105

So most probably the error means that there is no connection to the internet. Hence, check that the internet connection is set up properly (on the machine that runs your code, and more specifically so that python can make use of it).

Update

My answer refers to the original question, where a different domain was mentioned. The domain referenced in the question now is unknown:

$ nslookup es_search_demo.com
(...)

** server can't find es_search_demo.com: NXDOMAIN
miraculixx
  • 10,034
  • 2
  • 41
  • 60
0

Seems like your DNS server can't find an address associated to the URL you are passing

AndreyF
  • 1,798
  • 1
  • 14
  • 25