Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

uWSGI says no python application found for a Flask app

Error--- no python application found, check your startup logs for errors ---

Short answer

uWSGI loaded your file but did not find a WSGI callable to serve. By default it looks for an object named application, while Flask apps are usually called app. Pass --callable app. If the log shows an import error instead, fix the path, working directory or virtualenv.

  • Applies to uWSGI 2.0, Flask 3, Python 3.12
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the lines above the message in the uWSGI startup log. An import error or traceback there is the real cause; if there is none, it is the callable name.

    uwsgi --ini app.ini 2>&1 | head -n 60
  2. 2Match what you see, then jump to its fix

    1. 1No traceback in the log, and your file has app = Flask(__name__)The WSGI object is not called applicationFix
    2. 2A Python traceback or ModuleNotFoundError appears above the messageThe file fails to import (wrong path, missing package)Fix

What does the error look like?

  • --- no python application found, check your startup logs for errors ---

Cause 1 of 2

The WSGI object is not called application

1Check

The uWSGI Python loader looks for a function named application unless told otherwise.

grep -n "Flask(" *.py

2Fix

Name the object with --callable.

uwsgi --socket 127.0.0.1:3031 --wsgi-file myflaskapp.py --callable app

3Verify

The log lists the WSGI app as loaded instead of the error line.

uwsgi --ini app.ini 2>&1 | grep -i "WSGI app"

Confirmed by uwsgi-docs.readthedocs.io

Did this fix it?

Cause 2 of 2

The file fails to import (wrong path, missing package)

1Check

uWSGI takes its virtualenv from the virtualenv option, so packages installed elsewhere may not be found. Relative paths depend on the working directory too.

pwd
ls /path/to/venv/bin/python

2Fix

Set the virtualenv and the working directory in the ini file.

[uwsgi]
socket = 127.0.0.1:3031
chdir = /srv/myproject
wsgi-file = myflaskapp.py
callable = app
virtualenv = /path/to/venv

3Verify

Restart uWSGI. The log shows no traceback.

uwsgi --ini app.ini 2>&1 | grep -i "traceback\|error" || echo clean

Confirmed by uwsgi-docs.readthedocs.io

Did this fix it?

How do I stop it coming back?

  • Keep uWSGI options in an ini file under version control, not in a long command.
  • Use socket (or http-socket) with nginx and http only for local tests.
  • Read the first 60 lines of the uWSGI log after every deploy.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.