uWSGI says no python application found for a Flask app
--- 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.
Fix it fast
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 602Match what you see, then jump to its 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(" *.py2Fix
Name the object with --callable.
uwsgi --socket 127.0.0.1:3031 --wsgi-file myflaskapp.py --callable app3Verify
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
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/python2Fix
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/venv3Verify
Restart uWSGI. The log shows no traceback.
uwsgi --ini app.ini 2>&1 | grep -i "traceback\|error" || echo cleanConfirmed by uwsgi-docs.readthedocs.io
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:
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
- MenuloA restaurant discovery platform in Germany, kept current by a Python ingestion pipeline.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Servers
uWSGI fails at start with Fatal Python error: init_fs_encoding
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
uWSGI embeds Python and could not find that Python's standard library, so it failed before any of your code ran.
3 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
pip install cryptography tries to compile and fails in a Docker build
fatal error: 'openssl/aes.h' file not found
cryptography ships prebuilt wheels.
3 causes, each with a fixServers
cv2.imshow raises 'not implemented' because the wrong OpenCV package is installed
cv2.imshow() works in one environment and fails in another
The headless OpenCV packages are built without any GUI code, so cv2.imshow cannot open a window.
2 causes, each with a fixServers
pip install Cython succeeded, but the shell cannot find cythonize
a pip warning that a script was installed to a directory outside PATH
pip put the cythonize script in a folder your shell does not search.
3 causes, each with a fixServers
Django returns a 500 behind Gunicorn and the traceback is nowhere
The traceback shows locally with runserver but not under Gunicorn
With DEBUG set to False, Django's default logging does not print errors to the console.
2 causes, each with a fix