title: python 3.6 "Max retries exceeded with url"
body: <p>I am using requests to signIn server and I get the error below: </p>
  
  <blockquote>
    <p>[2018-01-12 11:56:43,931] {base_task_runner.py:95} INFO - Subtask: requests.exceptions.ConnectionError: HTTPConnectionPool(host='XX.XX.XX.XX', port=80): Max retries exceeded with url: /public-api/sign-in (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))</p>
  </blockquote>
  
  <p>I searched on stackoverflow and Google. And I tried many methods:</p>
  
  <ol>
  <li>set keep_alive = False</li>
  <li>set Header: Coonection = 'close'</li>
  <li>add retry and sleep.</li>
  <li>restart server and client.</li>
  </ol>
  
  <p>The error is still the same.</p>
  
  <p>Can anybody help?</p>
  
  <p>I am using Python 3.6.3. And the script is used in airflow. </p>
  
  <p>Code is below:</p>
  
  <pre><code>    import requests
      from requests.adapters import HTTPAdapter
      from requests.packages.urllib3.util.retry import Retry
      s = requests.Session()
      retry = Retry(connect = 5, backoff_factor = 1)
      adapter = HTTPAdapter(max_retries = retry)
      s.mount('http://', adapter)
      s.keep_alive = False
      res = s.post(self.conn.host + '/sign-in', data = json.dumps({
          'name': "XXX",
          'pwd': "XXX"
      }))
      response = res.json()
  </code></pre>