Running the Development Server
Django comes with a lightweight development server for testing your application locally. It auto-reloads on code changes and provides helpful error pages. Never use it in production — it's designed for development only.
Development Server
The development server is started with python manage.py runserver. By default it runs on http://127.0.0.1:8000/. It auto-detects code changes and restarts automatically. The server provides detailed error pages with tracebacks when DEBUG=True.
QuerySets are LAZY — no DB hit until evaluated.
Server Commands
- Start server: python manage.py runserver
- Custom port: python manage.py runserver 8080
- Custom host: python manage.py runserver 0.0.0.0:8000
- The server auto-reloads when you save files
- Press Ctrl+C to stop the server
- Yellow warnings about migrations are normal initially
- Never use runserver in production — use Gunicorn/uWSGI instead
Running the Server
# Start the development server
# python manage.py runserver
# Output:
# Watching for file changes with StatReloader
# Performing system checks...
#
# System check identified no issues (0 silenced).
# March 19, 2026 - 12:00:00
# Django version 5.1, using settings 'mysite.settings'
# Starting development server at http://127.0.0.1:8000/
# Quit the server with CTRL-BREAK.
# Custom port:
# python manage.py runserver 3000
# Allow external access:
# python manage.py runserver 0.0.0.0:8000Tip
Tip
Django's dev server auto-reloads when you save files. No need to restart it manually during development.
Common Mistake
Warning
Using runserver in production. It's single-threaded and insecure. Use Gunicorn or uWSGI behind Nginx for production.
Practice Task
Note
(1) Start the server on port 3000. (2) Access it from another device using 0.0.0.0. (3) Observe the auto-reload on file changes.
Quick Quiz
Key Takeaways
- Django comes with a lightweight development server for testing your application locally.
- Start server: python manage.py runserver
- Custom port: python manage.py runserver 8080
- Custom host: python manage.py runserver 0.0.0.0:8000