Reputation: 1601
Ubuntu 12.04, nginx 1.2.0, uwsgi 1.0.3.
I start uwsgi with the following command:
uwsgi -s 127.0.0.1:9010 -M -t 30 -A 4 -p 4 -d /var/log/uwsgi.log
On each request nginx replies with 502 and uwsgi writes to log the following line:
-- unavailable modifier requested: 0 --
Upvotes: 90
Views: 50866
Reputation: 162
For me the fix was to remove the apt version of uwsgi-plugin-python3
and the plugin
ini/cli option and run pip install uWSGI
and then run uwsgi with /path/to/my/venv/bin/uwsgi --ini /path/to/my/file.ini
that is assuming you did your pip install in a venv of course.
Upvotes: 0
Reputation: 1424
Original answer
For Python 2 on Ubuntu 11.10, using upstart
, install the python plugin for uWSGI
with apt-get install uwsgi-plugin-python
and if you're using an ini file to configure your uWSGI
app, then add plugins = python
to the [uwsgi]
section and it should solve this problem.
Edit: Updated for Python 3 and Ubuntu 17.10
For Python 3 on Ubuntu 17.10, using systemd
, install the python plugin for uWSGI
with apt-get install uwsgi-plugin-python3
and if you're using an ini file to configure your uWSGI
app, then add plugins = python3
to the [uwsgi]
section and it should solve this problem.
For further information on getting started with python
/uWSGI
apps, including how to configure them using an ini
file then please take a look at this handy guide
Upvotes: 117
Reputation: 91
Modify your ini file by added plugins line.
[uwsgi]
plugins = python3
Upvotes: 8
Reputation: 8733
I'm using Ubuntu 18.04 with Python 3. Below is the exact config I used to get it working.
You must have the Python 3 uWSGI plugin installed:
apt install uwsgi-plugin-python3
Your Nginx site configuration should point to your uWSGI socket. Make sure the port matches the configuration in the later steps.
location / {
uwsgi_pass 127.0.0.1:9090;
include uwsgi_params;
}
Reload the Nginx config to reflect the changes you just made:
systemctl reload nginx
You can use command-line arguments or an ini file for configuration. I created uwsgi.ini
. Make sure the socket address matches your nginx config.
[uwsgi]
socket = 127.0.0.1:9090
chdir = /var/www
processes = 4
threads = 2
plugins = python3
wsgi-file = /var/www/app.py
My app.py just has a basic example:
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/plain')])
return [b"Hello World!"]
Now start the uWSGI server from the command line:
uwsgi uwsgi.ini
Upvotes: 2
Reputation: 38432
from http://uwsgi-docs.readthedocs.org/en/latest/ThingsToKnow.html, "To route requests to a specific plugin, the webserver needs to pass a magic number known as a modifier to the uWSGI instances. By default this number is set to 0, which is mapped to Python."
I'm using 9 for a bash script and it's working. the numbers and their meanings are on this page: http://uwsgi-docs.readthedocs.org/en/latest/Protocol.html
in my nginx configuration:
location ~ .cgi$ {
include uwsgi_params;
uwsgi_modifier1 9;
uwsgi_pass 127.0.0.1:3031;
}
Upvotes: 8
Reputation: 178
Im starting uwsgi from upstart on Ubuntu. I solved the problem by running apt-get install uwsgi-plugin-python
, and then adding plugins=python
to my application.ini in /etc/uwsgi/applications-available.
Upvotes: 15
Reputation: 1601
Solved by installing uwsgi-plugin-python3
plugin and adding --plugin python3
option to uwsgi
start command
Upvotes: 30