title: How to get errors from python requests when host is unreachable?
body: <p>im trying to make small watchdog script for pinging container with nginx.
  this is my code:</p>
  <pre><code>import requests
  import time
  url = 'http://localhost:1234/'
  response = ''
  
      
  def checkloop (url, response):
      
      try:
          response = requests.get(url)
          
          
  
      except requests.ConnectionError:
          
          print(&quot;Can't connect to the site, sorry&quot;)
      else:
          response.status_code == 200
      
          print(&quot;OK&quot;, response.status_code)
      
  while response == '':
      checkloop (url, response)
      time.sleep(5)
  </code></pre>
  <p>But i cant get error when host is in down state. script breaking. i always getting this error:</p>
  <pre><code>&quot;requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=1234): Max retries exceeded with url: / (Caused by NewConnectionError('&lt;urllib3.connection.HTTPConnection object at 0x10332e4c0&gt;: Failed to establish a new connection: [Errno 61] Connection refused'))&quot;
  </code></pre>
  <p>how i can get in print() 403 or 404 or another error when host is different when httpget 200 code? is it possible?</p>
  <p>or maybe you can advise to me already working watchdog for python or small manual how to do that?</p>