Gunicorn as the WSGI Server
Serve Django with a real app server.
Gunicorn as the WSGI Server is a free Django Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Django Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Meet Gunicorn
Django's runserver is great for coding, but it is single-threaded and unsafe for the public web. In production you need a real app server. 🚀
What WSGI Is
WSGI is the standard contract between a Python web app and a server. It lets any server talk to Django without knowing its internals.
Gunicorn Speaks WSGI
Gunicorn is a production WSGI server that loads your Django app and runs it fast, stable, and concurrently across many requests.
Install It
Add Gunicorn to your environment with pip, then pin it in requirements.txt so every deploy uses the same version.
pip install gunicorn
pip freeze > requirements.txtThe wsgi.py Entry Point
Every project ships a wsgi.py exposing an object named application. Gunicorn imports exactly that object to serve your site.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()Run Gunicorn
Point gunicorn at your project's wsgi module. The dotted path mirrors how Python imports it, ending in application.
gunicorn myproject.wsgi:applicationBind an Address
Use --bind to choose the host and port. Binding to 0.0.0.0 lets the outside world reach the server, not just localhost.
gunicorn myproject.wsgi --bind 0.0.0.0:8000Workers Handle Load
Each worker is a process serving requests in parallel. A common start is 2 times CPU cores plus 1, then tune from real traffic.
gunicorn myproject.wsgi --workers 3Gunicorn Is Not for Static
Gunicorn runs your Python code, not files. Serving CSS and images is a job you hand to Nginx or WhiteNoise instead.
Keep It Running
A live server must survive reboots and crashes. A process manager like systemd restarts Gunicorn automatically so your site stays up.
Timeouts Matter
The --timeout flag kills workers stuck on slow requests. The default is 30 seconds, which protects you from one hung view freezing everything.
gunicorn myproject.wsgi --timeout 60Quick Check
Let's confirm what Gunicorn actually serves.
Recap
You learned that Gunicorn is the production WSGI server that runs Django via wsgi:application, scales with workers, and leaves static files to others. 🎯
Frequently asked questions
Is the “Gunicorn as the WSGI Server” lesson free?
Yes — the full text of “Gunicorn as the WSGI Server” is free to read here on the web, and the Django Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Django Academy course, upgrade to CoddyKit PRO.
What will I learn in “Gunicorn as the WSGI Server”?
Serve Django with a real app server. You practise Django Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Django Academy?
No prior experience is required. Django Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Gunicorn as the WSGI Server” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Django Academy lesson?
Yes. Every Django Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Gunicorn as the WSGI Server
- Nginx as a Reverse Proxy
- WhiteNoise for Static Files
- Environment Variables and Settings Split