Port 8000

What’s running on port 8000 on my Mac?

8000 is the Python and PHP world’s 3000. Django, FastAPI, Laravel and Python’s built-in file server all start there, and the last one shares your folder with the whole network by default.

Commonly used by

  • Djangopython manage.py runserver serves on 127.0.0.1:8000.
  • FastAPI / uvicornfastapi dev and uvicorn main:app default to 127.0.0.1:8000.
  • Laravelphp artisan serve runs PHP’s built-in server on 127.0.0.1:8000.
  • python -m http.serverServes the current folder on port 8000, on every interface.
  • Gatsby / MkDocsgatsby develop and mkdocs serve also use 8000.

Check what’s on port 8000

lsof -nP -iTCP:8000 -sTCP:LISTEN
ps -o pid,etime,command -p <PID>

The full command line separates the usual suspects:

Command line containsTool
manage.py runserverDjango
uvicorn / fastapiFastAPI or another ASGI app
php -S or artisan serveLaravel / PHP built-in server
http.serverPython’s file server
node … gatsbyGatsby

Django’s autoreloader runs two Python processes; the child holds the port, and killing the parent stops both.

With Stat Space: statspace port 8000.

Change the port

ToolCommand
Djangopython manage.py runserver 8001
FastAPIfastapi dev main.py --port 8001 or uvicorn main:app --port 8001
Laravelphp artisan serve --port=8001
Python file serverpython3 -m http.server 8001 --bind 127.0.0.1
Gatsbygatsby develop -p 8001
MkDocsmkdocs serve -a 127.0.0.1:8001

Laravel will try 8001, 8002 and so on by itself if 8000 is busy. Django and uvicorn fail instead.

Who can reach it

Django, uvicorn and artisan bind to 127.0.0.1 by default, so they’re local unless you pass 0.0.0.0:8000 or --host 0.0.0.0. Two exceptions catch people out:

  • python3 -m http.server listens on all interfaces. Run it in your home folder and anyone on the network can browse your files. Always add --bind 127.0.0.1.
  • Django with DEBUG = True on 0.0.0.0 shows full tracebacks with settings and environment details to anyone who triggers an error.

Check with lsof: *:8000 means reachable from the network. More in dev server exposed to the network.

Seeing it live

Stat Space shows 8000 with the framework it detected (Django and other common ones), the project folder and the launcher, and flags *:8000 bindings such as a forgotten http.server in your home folder.

Questions

How do I run Django on a different port?

Pass it as an argument: python manage.py runserver 8001. For another address too: python manage.py runserver 127.0.0.1:8001.

Why does Django say 'That port is already in use'?

Another runserver (often from another project or a crashed terminal) still holds 8000. Find it with lsof -nP -iTCP:8000 -sTCP:LISTEN and stop it with kill <PID>.

Is python -m http.server safe to use?

It's fine for local testing, but it binds to all interfaces and serves every file under the folder you ran it from. Add --bind 127.0.0.1 to keep it on your Mac.

Get started

Know what your Mac is doing, without adding to it.

Free, no account. Pro is $9.99 once for the first 100 buyers.