localhost:8000 (Django, PHP, Python): not working and fixes
Port 8000 is used by Django, PHP’s built-in server and Python’s http.server. How to open it, and fix refused to connect and port in use.
Open this address: http://localhost:8000This opens on your own computer. It only works if the program is running.
localhost:8000 is a very common address for Django, PHP and Python development servers. It only works while the server is running in a terminal on your computer.
What runs on localhost:8000
- Django with
python manage.py runserver - PHP built-in server with
php -S localhost:8000 - Python static files with
python3 -m http.server 8000 - FastAPI with Uvicorn
Commands to start and test port 8000
python manage.py runserver 8000php -S localhost:8000python3 -m http.server 8000uvicorn main:app --reload --port 8000Find what is using port 8000
Run these in a terminal on your computer. Nothing is sent to this site.
If localhost:8000 will not open
- This site can’t be reached (ERR_CONNECTION_REFUSED)
- The server is not running. Start it in a terminal and keep that terminal open. See the full checklist.
- Port 8000 is already in use
- Find what is using it with the tool below, or start on another port, for example
runserver 8001. - Invalid HTTP_HOST header (Django)
- You opened the site with a host name Django does not know. Add it to
ALLOWED_HOSTSin settings.py. - PHP shows a blank page or 404
- The folder has no index.php or index.html. Start the server from your project folder.
- Works on localhost, not on your phone
- Start with
0.0.0.0:8000and use your computer’s IP address. See how to open localhost from your phone. - Django: python: can’t open file manage.py
- You are in the wrong folder.
cdinto the folder that contains manage.py, then runpython manage.py runserver. - Django: it works only on localhost
python manage.py runserver 0.0.0.0:8000listens on your network. Add your computer’s IP toALLOWED_HOSTSin settings.py, or you get the Invalid HTTP_HOST error.- FastAPI: Error loading ASGI app
- The module path is wrong. For a file main.py containing
app = FastAPI()runuvicorn main:app --reload --port 8000from that folder. - python -m http.server serves the wrong folder
- It serves the folder you ran it from. Change into the right folder first, or use
--directory. Add--bind 127.0.0.1to keep it private. - Started with python -m http.server
- That command uses port 8000 unless you pass another number, and listens on all interfaces by default. See how to change the port, folder and who can connect.
Other ports like 8000
| Port | Usually used by |
|---|---|
| localhost:3000 | React, Next.js, Express |
| localhost:5173 | Vite dev server |
| localhost:4200 | Angular dev server |
| localhost:5000 | Flask |
| localhost:8080 | Tomcat, Spring Boot, Docker |
| localhost:8888 | Jupyter Notebook |
| localhost:9000 | PHP-FPM, SonarQube |
Questions about localhost:8000
- What runs on localhost:8000?
- Most often Django (runserver), the PHP built-in server, Python's http.server, or FastAPI with Uvicorn.
- How do I stop the server on port 8000?
- Press Ctrl+C in the terminal where it is running. If you cannot find that terminal, use the port checker below to find the process and stop it.
- Django, PHP or Python: which one is on port 8000?
- Any of them may be. The terminal where you started the server shows which. The port checker below shows the program name.