Andre
Andre

Reputation: 1357

Why does Flask produce a ERR_CONNECTION_RESET?

Python code on sever:

from flask import *
from flask_cors import CORS

app = Flask(__name__)
CORS(app)

@app.route('/')
def index():
    return Response('Index')
if __name__ == '__main__':
    app.run(debug=True, host='***.***.***.***', port=80, ssl_context=('certificates/cert.pem', 'certificates/key.pem'))

the cert.pem and key.pem files have been generated using:

openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365

and the tutorial available here and they will be soon updated using certbot.

I also tried to check with curl the output using: curl -i https://***.***.***.***:80 -k >> CurlOutput.txt but the file is empty.

Is there a way to keep the current certificate until certbot's certificate is ready and also to solve the connection problem?

Upvotes: 1

Views: 1012

Answers (1)

Erik Dz
Erik Dz

Reputation: 105

You're using port 80 to serve SSL. Use port 443 which is destined for HTTPS. Had the same error and this solved it for me.

So simply change the last line to:

if __name__ == '__main__':

    app.run(debug=True, host='***.***.***.***', port=443, ssl_context=('certificates/cert.pem', 'certificates/key.pem'))

Upvotes: 1

Related Questions