← Back to Django Course | Chapter 1: Django Fundamentals & Setup | Lesson 8 of 9

Running the Development Server

The development server is a mini web server on your own computer that lets you preview your Django site before anyone else sees it.

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.

bash
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.

bash
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.

bash
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.

bash
pip install gunicorn
gunicorn mysite.wsgi:application

⚠️ Run this command in your terminal.

Common Mistakes
  1. Forgetting to apply migrations before running the server, causing database errors on first load.
  2. Running the server outside the project folder where manage.py does not exist.
  3. Using the development server in production instead of a proper production web server.
Chapter Summary
  • 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.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.