Skip to content
Advertisement

Python HTTPConnectionPool Failed to establish a new connection: [Errno 11004] getaddrinfo failed

I was wondering if my requests is stopped by the website and I need to set a proxy.I first try to close the http’s connection ,bu I failed.I also try to test my code but now it seems no outputs.Mybe I use a proxy everything will be OK? Here is the code.

JavaScript

and the error is the here!

JavaScript

By the way, When I test my code at first it shows everything is OK! Thanks in advance!

Advertisement

Answer

It seems to me you’re hitting the limit of connection in the HTTPConnectionPool. Since you start 10 threads at the same time

Try one of the following:

  1. Increase the request timeout (seconds): requests.get('url', timeout=5)
  2. Close the response: Response.close(). Instead of returning response.text, assign response to a varialble, close Response, and then return variable
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement