Upsun User Documentation

Switch from the Flask server to another web server

Back to home

On this page

Upsun Beta access

Test and provide feedback for our newest offering - Upsun!

You can register for the Beta by clicking here and completing the form.

Sign up for Beta access

While lightweight and easy to use, Flask’s built-in server is not suitable for production as it doesn’t scale well.
Upsun supports several different web servers for Python that you can use instead. Choose your server depending on your app and specific requirements.

The following instructions allow you to switch to Gunicorn. If you choose another web server, you may need to take different steps.

To switch to Gunicorn web server, follow these steps:

  1. Open your .upsun/config.yaml file, and locate the section dedicated to the web server:

    .upsun/config.yaml
    web:
      commands:
        start: "flask run -p $PORT"
      upstream:
        socket_family: tcp

    Change the start command:

    .upsun/config.yaml
    web:
      # Commands are run once after deployment to start the application process.
      commands:
        # The command to launch your app. If it terminates, it’s restarted immediately.
        # You can use the $PORT or the $SOCKET environment variable depending on the socket family of your upstream
        start: "gunicorn -w 4 'autoapp:app'"
  2. Commit your changes and push them to your environment. To do so, run the following commands:

    Terminal
    git add .upsun/config.yaml
    git commit -m "Changes project to use Gunicorn"
    upsun environment:push -y

Next steps Anchor to this heading

Is this page helpful?