{"id":3848,"library":"uwsgi","title":"uWSGI Server","description":"uWSGI is an open-source, fast, and self-healing application server container that serves as a full stack for building hosting services. It is primarily known for efficiently running Python WSGI applications but supports various other languages and protocols (like Ruby/Rack, Perl/PSGI, PHP, Go) through its pluggable architecture. The current stable version is 2.0.31. The project has been in maintenance mode since October 2022, focusing on stability rather than new features.","status":"maintenance","version":"2.0.31","language":"en","source_language":"en","source_url":"https://github.com/unbit/uwsgi","tags":["web server","wsgi","deployment","application server","cpython","http","fastcgi"],"install":[{"cmd":"pip install uwsgi","lang":"bash","label":"Install latest stable release"}],"dependencies":[{"reason":"uWSGI is primarily a C application and often compiles from source during `pip install`.","package":"C compiler (e.g., gcc, clang)","optional":false},{"reason":"Required for building uWSGI with Python support.","package":"Python development headers (e.g., python-dev, python-devel)","optional":false}],"imports":[{"note":"The `uwsgi` module is automatically injected into Python applications *only when they are run by the uWSGI server*. It provides access to server configuration, internal functions, and statistics. Attempting to import it outside of a uWSGI context will raise an ImportError.","wrong":"import uwsgi (when not running under uWSGI)","symbol":"uwsgi","correct":"import uwsgi"}],"quickstart":{"code":"import os\n\ndef application(environ, start_response):\n    status = '200 OK'\n    headers = [('Content-type', 'text/plain')]\n    start_response(status, headers)\n    return [b\"Hello from uWSGI and Python!\"]\n\n# To run: save this as `wsgi_app.py`\n# Then execute from your terminal:\n# uwsgi --http :9090 --wsgi-file wsgi_app.py --callable application --processes 1 --threads 1","lang":"python","description":"This quickstart demonstrates how to create a basic WSGI 'Hello World' application and run it using the `uwsgi` command-line tool. The `--http` option binds to an HTTP port, `--wsgi-file` specifies your application file, `--callable` points to the WSGI callable, and `--processes`/`--threads` configure concurrency."},"warnings":[{"fix":"Ensure `build-essential` (Debian/Ubuntu) or `Development Tools` (Fedora/RHEL) and `python-dev`/`python-devel` are installed on your system. Alternatively, consider using `pyuwsgi` which provides pre-built wheels and includes common libraries.","message":"Installing `uwsgi` via `pip` often fails without system-level build tools (C compiler, Python development headers). This is because uWSGI is a C application that gets compiled during installation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Enable Python threads by adding `--enable-threads` (command line) or `enable-threads = true` (configuration file) to your uWSGI configuration. Running in multithreading mode (with `threads` option) automatically enables it.","message":"Python threads are disabled by default within uWSGI's Python plugin. Application-generated threads will not run unless explicitly enabled.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always place a reverse proxy (like Nginx or Apache) in front of uWSGI instances to sanitize/validate requests and proxy them using the `uwsgi` protocol.","message":"Never expose a socket speaking the native `uwsgi` protocol directly to the public network, as it allows dynamic loading of applications (arbitrary code execution).","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure your WSGI application or framework fully reads the request `wsgi.input` stream when a request body is expected.","message":"If an HTTP request contains a body (e.g., POST request from a form), your application *must* read (consume) the entire body. Failure to do so can 'clobber' the communication socket with the web server, leading to hung connections or errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Set appropriate permissions for the UNIX socket using the `--chmod-socket` option (e.g., `--chmod-socket=666` or specific user/group permissions) so your web server can access it.","message":"When using UNIX sockets, they are filesystem objects subject to standard UNIX permissions. If your web server lacks write access, it cannot communicate with uWSGI.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Increase the buffer size with the `--buffer-size` option (e.g., `--buffer-size 8192`) up to 65535 bytes, based on your application's needs.","message":"Receiving 'invalid request block size' errors in logs often indicates that the default internal buffer size (4096 bytes) for request headers is too small.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Start uWSGI as `root` if necessary for binding to privileged ports, but immediately drop privileges to a non-root user and group using the `uid` and `gid` options.","message":"Running uWSGI instances directly as the `root` user is a security risk.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}