Reputation: 39
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',))
Upvotes: 2
Views: 70531
Reputation: 11
RESTART THE PC OR INTERNET (my solve)
Hi, for strange to seem, i had the same problem in a remote pc handled with "AnyDesk" program. At the same time that i was using the anydesk with internet, the internet itself doesnt been working, neither firefox open any web nor requests library in python be able to get info from any web, nor any ping answer from "google.com", like if anydesk does some change in the internet configuration. The problem i solve restarting the remote pc. Its working now. (its proper say that my codes had worked perfect until yesterday, and without touched anything they broke)
original en español y resumido: Tuve el mismo problema con una pc, de repente los codigos que abrian internet con "requests", la libreria de python, dejaron de funcionar, y daban "requests.exceptions.ConnectionError: HTTPConnectionPool(host='es_search_demo.com', port=80): Max retries exceeded with url: "my_url" (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f544af9a5d0>: Failed to establish a new connection: [Errno -2] Name or service not known',)) como esto era desde Odoo probé desde un terminal desde el root, tampoco funcionaba, probé el ping www.google.com, tampoco funcionaba, asique abri un navegador y vi que no habia internet (aun cuando yo estaba manejando esa pc desde AnyDesk, un poco desconcertado tener internet para una cosa y no para el resto). Cuando descubrí esto buscando solucion empecé a decidí por reiniciar la pc, y funcionó.
Upvotes: 1
Reputation: 10349
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
Upvotes: 8
Reputation: 1838
Seems like your DNS server can't find an address associated to the URL you are passing
Upvotes: 0