gunicorn
python WSGI HTTP server for Unix
TLDR
Run a WSGI application
SYNOPSIS
gunicorn [options] APPMODULE_
DESCRIPTION
Gunicorn (Green Unicorn) is a Python WSGI HTTP server for Unix systems, designed to serve web applications in production using a pre-fork worker model. A master process manages a pool of worker processes, each of which independently handles incoming requests. The application is specified as module:variable (e.g., `myapp:app` for Flask or `myproject.wsgi:application` for Django), and the recommended worker count is (2 x CPU cores) + 1 to balance concurrency against memory usage.
The default synchronous worker handles one request at a time per process, which is suitable for CPU-bound applications. For I/O-bound workloads with many concurrent connections, async worker classes such as `gevent` or `eventlet` use cooperative multithreading to multiplex thousands of connections within fewer processes, while the `gthread` worker uses OS threads. Workers that exceed the configurable timeout are automatically killed and restarted by the master process, providing resilience against hung requests.
In production, Gunicorn typically runs behind a reverse proxy like Nginx, which handles SSL termination, static file serving, and request buffering. Communication between the proxy and Gunicorn occurs over HTTP or a Unix domain socket.
PARAMETERS
-b, --bind ADDRESS
Socket to bind (HOST:PORT, unix:PATH, or fd://FD).-w, --workers INT
Number of worker processes (default: 1).-k, --worker-class STRING
Worker type: sync, gevent, eventlet, tornado, gthread.--threads INT
Threads per worker (for gthread worker).-t, --timeout INT
Worker timeout in seconds (default: 30).--graceful-timeout INT
Timeout for graceful worker restart.--reload
Restart workers when code changes (development only).-D, --daemon
Daemonize the process.-p, --pid FILE
PID file path.--access-logfile FILE
Access log file (- for stdout).--error-logfile FILE
Error log file (- for stderr).--log-level LEVEL
Logging level: debug, info, warning, error, critical.-c, --config FILE
Configuration file path.--preload
Load application code before forking workers.-n, --name STRING
Process name for ps output.-u, --user USER
Switch worker processes to run as this user.-g, --group GROUP
Switch worker process to run as this group.
CAVEATS
Not designed for Windows. Sync workers block on slow clients without buffering proxy. --reload is for development only. Preload can cause issues with some frameworks. Workers are killed after timeout regardless of what they're doing.
HISTORY
Gunicorn was created by BenoƮt Chesneau, with the first release around 2010. The name is a portmanteau of "Green Unicorn." It was designed as a Python port of Ruby's Unicorn server, bringing its pre-fork architecture to Python. Gunicorn has become one of the most popular WSGI servers for Python web applications.
SEE ALSO
uvicorn(1), uwsgi(1), nginx(8), flask(1), django-admin(1)
