title: Flask-Python redirection to https The connection was reset
body: <p>I am a new Flask user and i have a problem. I want to redirect all url from http to https but I am having this error:</p>
  
  <blockquote>
    <p>The connection was reset</p>
  </blockquote>
  
  <p>This is my Flask code:</p>
  
  <pre><code>#! /usr/bin/python
  # -*- coding:utf-8 -*-
  
  from flask import *
  from OpenSSL import SSL
  import psycopg2
  import os
  from datetime import timedelta
  import sys
  from flask_sslify import SSLify
  reload(sys)  
  sys.setdefaultencoding('utf8')
  db_conn = psycopg2.connect("dbname=billjobs host=192.168.42.96 port=50434 user=username password=password")
  
  app = Flask(__name__)
  db = db_conn.cursor()
  app.permanent_session_lifetime = timedelta(seconds=900)
  sslify = SSLify(app)
  app.secret_key='\xatYK\x1ba\x1dz\xa6-D\x9d\x97\x83\xfa\xcf\xcbd\xfa\xfb\x1a|\x08\x1af'
  context = ('ssl.crt','ssl.key')
  @app.route('/')
  def pre_log():
      return render_template('index.html')
  if __name__ == '__main__':  
      app.run(host="192.168.42.186", ssl_context=context, debug=False)
  </code></pre>
  
  <p>If I enter directly the address <strong><em>https</em></strong>://192.168.42.186:5000 it work but with <strong><em>http</em></strong> only its not</p>
  
  <p>Thanks for helping me in advance</p>