Run Flask as a Windows Service with AlwaysUp

How to Run Flask 24/7 as a Windows Service with AlwaysUp

Ensure that your Flask application starts immediately whenever your PC boots — no need to log in first

Flask is a popular lightweight Python-based web application framework.

Flask includes a built-in development server, which supports non-production use. We'll show you how to run your application continuously with that server.


To install your Flask application as a Windows Service with AlwaysUp:

  1. First, ensure that your Flask app starts from the command line and works as expected. If Flask doesn't work at this point, it won't work with AlwaysUp either!

    For this tutorial, we deployed a simple web application in "C:\web\projects\testproject". The code is in a file named "time-server.py":

    Flask application deployed

    Notice that Flask created the ".venv\Scripts" sub-folder (which contains the executable files) as part of the installation process:

    Flask executable files installed

    With this configuration, here is the full command line we use to run our application from a command prompt:

    C:\web\projects\testproject\.venv\Scripts\flask.exe --app time-server run

    Note that the command must run from the "C:\web\projects\testproject" folder so that it can find the time-server python script. Otherwise, we'd have to specify the full path to the .py file in the command line.

    In any case, we verified that our command line started Flask and the simple application worked as expected:

    Flask application running

  2. Download and install AlwaysUp, if necessary.

  3. Start AlwaysUp.

  4. Select Application > Add to open the Add Application window:

    Add Application on Windows Server 2025

  5. On the General tab:

    1. In the Application field, enter the full path to the Flask executable, flask.exe. This will likely reside in the ".venv\Scripts" sub-folder where you deployed your Flask app.

    2. In the Arguments field, enter the parameters for your command line that starts your Flask application (from step #1).

    3. In the Start in directory field, enter the folder where you deployed your Flask application.

    4. In the Start the application field, select Automatically, but shortly after the computer boots.

      This setting — which delays Flask by about 2 minutes after a reboot — should ensure that critical system services (like networking and security) are ready and waiting when Flask starts automatically with Windows.

    5. And in the Name field, enter the name that you will call the application in AlwaysUp. We have used Flask app but feel free to specify a different name if you like.

    Flask Windows Service: General Tab

  6. Move to the Logon tab and enter the user name and password of the Windows account where you installed Python and Flask.

    Flask Windows Service: Logon Tab

  7. We're done configuring Flask so click the Save button to record your settings. In a couple of seconds, an entry named Flask app (or whatever you called it) will show up in the AlwaysUp window. It is not yet running though and its state will be "Stopped":

    Flask Windows Service: Installed

  8. To start Flask, choose Application > Start "Flask app". The state should soon transition to "Running" and Flask will be working in the background:

    Flask Windows Service: Running

    And with Flask running as a Windows Service, please confirm that your Flask app is available from your browser.

    Everything looked good on our system:

    Confirm that Flask is working as expected

  9. That's it! Next time your computer boots, your Flask application will start up immediately, in the background, without anyone needing to log on. Please restart your PC now and test that everything works as expected after Windows comes back to life.

    And please feel free to edit Flask in AlwaysUp and explore the many other settings that may be appropriate for your environment. For example, send an email if Flask stops, boot priority to give it more CPU, or recycle it weekly to cure memory leaks.



Flask app not working properly as a Windows Service?

  • Consult the AlwaysUp Troubleshooter — our online tool that can help you resolve the most common problems encountered when running an application as a Windows Service.

  • From AlwaysUp, select Application > Report Activity > Today to bring up an HTML report detailing the interaction between AlwaysUp and Flask/Python. The AlwaysUp Event Log Messages page explains the messages that may appear.

  • Browse the AlwaysUp FAQ for answers to commonly asked questions and troubleshooting tips.

  • Contact us and we'll be happy to help!

Download & Try it Free!

Download AlwaysUp and Run as a Service Today! Version 15.5 New!

8.0 MB Installer
Our 12,000+ customers include...
Compatible with Windows 11 Compatible with Windows Server 2022 Compatible with Windows 10
Over 94,000 installations, and counting!
 
AlwaysUp is number 1! Run as a Service with AlwaysUp

Rock-solid for the past 19+ years!