Running the Development Server
In this page:
Starting the Development Server
Running "python manage.py runserver" from the project folder starts a local web server, and Django prints the address where you can view your site in a browser.
Example: Starting the Development Server
Starts Django's built-in development server on the default port.
python manage.py runserver
⚠️ Run this command in your terminal.
Choosing a Different Port
Adding a port number after runserver, like "python manage.py runserver 8080", starts the server on that port instead of the default 8000.
Example: Choosing a Different Port
Starts the development server on port 8080 instead of the default.
python manage.py runserver 8080
⚠️ Run this command in your terminal.
Auto-Reload on Code Changes
The development server watches your Python files and automatically restarts itself whenever you save a change, so you rarely need to stop and start it manually.
Example: Auto-Reload on Code Changes
StatReloader watches every .py file in the project; saving one prints this line and restarts the server for you automatically — no manual stop/start needed.
python manage.py runserver
Watching for file changes with StatReloader
⚠️ Run this command in your terminal.
Why Not to Use It in Production
The development server is single-threaded and not optimized for security or performance under real traffic, so production sites use servers like Gunicorn behind Nginx instead.
Warning: Never deploy a live site using "runserver" directly — it is explicitly for development only.
Example: Why Not to Use It in Production
This is the real command that replaces runserver in production — Gunicorn (usually paired with Nginx) is a production-grade WSGI server; runserver is single-threaded and refuses that role on purpose.
pip install gunicorn
gunicorn mysite.wsgi:application
⚠️ Run this command in your terminal.
- Forgetting to apply migrations before running the server, causing database errors on first load.
- Running the server outside the project folder where manage.py does not exist.
- Using the development server in production instead of a proper production web server.
- The command "python manage.py runserver" starts Django's built-in development server.
- By default it runs on http://127.0.0.1:8000/.
- The server auto-reloads when you save changes to Python files.
- It is meant for local development only, never for production traffic.
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: