Fail to deploy flask app in port 443 with the certificate, but I can host it in port 8080 in Azure VM

Nysus 0 Reputation points
2024-10-07T03:28:49.7433333+00:00

This is the sample flask app.
if name=='main':

app.run(debug=True,host="0.0.0.0",port=443,ssl_context=('xxx.crt', 'yyy.key'))

And for my xyz.sh file for executing the flask app automatically.
#!/bin/bash

cd /filepath/to/my/flask_app

exec sudo python3 flask_app.py

And the service file should work fine as it can be used for port 8080.

This is my internal network setting of the virtual machine, I have opened the port 443User's image

Yet, the current virtual machine gives the following output when I check the status of the app.

× flask_app.service - Flask Application

 Loaded: loaded (filepath/flask_app.service; enabled; preset: enabled)

 Active: failed (Result: exit-code) since Mon 2024-10-07 11:26:28 HKT; 2s ago

Duration: 13ms

Process: 15112 ExecStart=filepath/start_flask.sh (code=exited, status=1/FAILURE)

Main PID: 15112 (code=exited, status=1/FAILURE)

    CPU: 9ms

Oct 07 11:26:28 LICSVR01 systemd[1]: flask_app.service: Scheduled restart job, restart counter is at 5.

Oct 07 11:26:28 LICSVR01 systemd[1]: flask_app.service: Start request repeated too quickly.

Oct 07 11:26:28 LICSVR01 systemd[1]: flask_app.service: Failed with result 'exit-code'.

Oct 07 11:26:28 LICSVR01 systemd[1]: Failed to start flask_app.service - Flask Application.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
43,230 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.