How to run a Django development server on a different port number

Published on Aug. 22, 2023, 12:13 p.m.

When you start your Django development server it runs on port 8000 by default.

$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
October 19, 2020 - 12:19:16
Django version 3.1.1, using settings 'api.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

To start the development server on a different port number you pass it as an argument.To run the development server on port 8001 that would make the command python .

$ python manage.py runserver 8001
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
October 19, 2020 - 12:20:38
Django version 3.1.1, using settings 'api.settings'
Starting development server at http://127.0.0.1:8001/
Quit the server with CONTROL-C.

Run on port 80

You most likely have to use sudo in order to run the server.One way to work around that is by using the full path to the python.

$ sudo /home/../venv/bin/python manage.py runserver 80

If you have installed Apache on your system, than port 80 is probably already in use.

Error: That port is already in use

If that’s the case, then stop those services first.

$ sudo service apache2 stop

For NGINX

$ sudo service nginx stop

Now you should be all set to run the Django server on port 80.

$ sudo /home/../venv/bin/python manage.py runserver 80
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
October 19, 2020 - 12:42:55
Django version 3.1.1, using settings 'api.settings'
Starting development server at http://127.0.0.1:80/
Quit the server with CONTROL-C.

$ python manage.py runserver --help

Tags: