Django Error: That port is already in use (tested)

python manage.py runserver prints Error: That port is already in use. when another process, usually an earlier runserver, already listens on port 8000. Start on another port, or find and stop the old process.

1. Reproduce it

A fresh django-admin startproject mysite, one runserver 8000 left running in the background, then a second one started. The script:

export PYTHONUNBUFFERED=1
python manage.py runserver 8000 --noreload > first.log 2>&1 &
i=0; until grep -q "Quit the server" first.log || [ $i -gt 100 ]; do sleep 0.2; i=$((i+1)); done
echo '$ python manage.py runserver 8000'
python manage.py runserver 8000 --noreload 2>&1 | grep -v "^$" | tail -2
echo '$ python manage.py runserver 8001'
timeout 3 python manage.py runserver 8001 --noreload 2>&1 | grep -E "Starting|Quit"

Output:

$ python manage.py runserver 8000
Run 'python manage.py migrate' to apply them.
Error: That port is already in use.
$ python manage.py runserver 8001
Starting WSGI development server at http://127.0.0.1:8001/
Quit the server with CONTROL-C.
Terminated

Only one process can listen on a port. The second runserver prints Error: That port is already in use. and exits; on another port it starts normally (the Terminated line is just timeout stopping it). The usual culprit is an earlier runserver still running: in another terminal, an IDE run configuration, a process left behind after closing a terminal, or a container publishing the same port.

2. Fix

  1. Use another port right away: python manage.py runserver 8001 (shown above).
  2. Find what holds the port: on Linux ss -ltnp | grep :8000 or lsof -i :8000, on macOS lsof -i :8000, on Windows netstat -ano | findstr :8000. The output gives the PID.
  3. Stop that process if it is your old dev server: kill <PID> (or taskkill /PID <PID> on Windows). If it is a Docker container, stop that container instead.

The same situation in plain Python raises OSError: [Errno 98] Address already in use; see Errno 98 Address already in use and EADDRINUSE. Related: Docker port is already allocated.

Frequently asked questions

How do I fix 'That port is already in use' in Django?

Run on another port (python manage.py runserver 8001) or find the process on port 8000 with lsof -i :8000 / netstat -ano and stop it.

Why is port 8000 already in use when no server is open?

An earlier runserver is often still running in another terminal, an IDE, or a container that publishes the port.

Written with AI assistance. Measured on 2026-10-23 with Django 6.1.2 and Python 3.14.7 (python:3-alpine in Docker). The script was run verbatim and the output pasted unedited. PlainHeaders is our extension; Python and Django are free.