title: Python requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.10.10.10', port=80): Max retries exceeded with url
body: <p>I'm writing a script to check a large list of URLs and return the HTTP status codes for each one. I tried everything I could think of, or find online for the exception handling. The script runs for a while, then it crashes eventually with the error:</p>
  
  <pre><code>requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.10.10.10', port=80): Max retries exceeded with url: /wmedia (Caused by NewConnectionError("&lt;urllib3.connection.HTTPConnection object at 0x1029bfe10&gt;: Failed to establish a new connection: [Errno 49] Can't assign requested address",))
  </code></pre>
  
  <p>I think the server gets overwhelmed with too many requests after a while, and the sleep time doesn't help.</p>
  
  <p>This is the worker function I'm using with process pool:</p>
  
  <pre><code>def get(url):
  r = requests.get(url, timeout=2)
  
  try:
      r.raise_for_status()
  except requests.exceptions.HTTPError as err:
      print(err)
      pass
  except requests.ConnectionError as e:
      print("OOPS!! Connection Error")
      r.status_code = "Connection refused"
      time.sleep(2)
      print(str(e))
  except requests.Timeout as e:
      print("OOPS!! Timeout Error")
      r.status_code = "Timed out"
      time.sleep(2)
      print(str(e))
  except requests.RequestException as e:
      print("OOPS!! General Error")
      r.status_code = "Error"
      print(str(e))
  except KeyboardInterrupt:
      print("Someone closed the program")
      r.status_code = "Interrupted"
  except Exception as e:
      print(e)
      r.status_code = "Error"
  
  return param, r.status_code 
  </code></pre>
  
  <p>Any suggestions?</p>