localhost:8000: Django, Laravel, FastAPI and Python Servers

localhost:8000 is where Python and PHP frameworks start their development servers. Django's runserver, Laravel's php artisan serve, uvicorn for FastAPI and python -m http.server all choose 8000 when you give no port. Refused means that server is not running; 'address already in use' means an earlier one still is.

Development servers that default to port 8000
FrameworkCommandUse another port
Djangopython manage.py runserverpython manage.py runserver 8001
Laravelphp artisan servephp artisan serve --port=8001
FastAPI (uvicorn)uvicorn main:app --reloaduvicorn main:app --port 8001
Python static filespython -m http.serverpython -m http.server 8001
Gatsbygatsby developgatsby develop -p 8001

Updated

Each of these servers is meant for development only, and each binds a little differently. Django, Laravel and uvicorn listen on 127.0.0.1 unless told otherwise, while Python's http.server listens on all addresses. That difference decides whether another device, or a container, can reach port 8000.

Free port 8000 or bind it for other devices

Stop the process holding 8000

lsof -t prints only the process ID, so it can feed kill directly on macOS and Linux.

kill $(lsof -t -iTCP:8000 -sTCP:LISTEN)

# Windows Command Prompt
netstat -ano | findstr :8000
taskkill /PID <PID> /F

Listen on every address, per framework

Use these only on a network you trust; they make the dev server reachable from other machines.

python manage.py runserver 0.0.0.0:8000
php artisan serve --host=0.0.0.0 --port=8000
uvicorn main:app --host 0.0.0.0 --port 8000
python -m http.server 8000 --bind 0.0.0.0

Refused to connect: fixes by framework

Django: a broken import, a missing migration error or a settings mistake can stop runserver before it binds. Read the traceback in the terminal. Laravel: artisan serve needs PHP on your PATH and a .env file; a missing APP_KEY shows an error page rather than a refusal.

FastAPI: if uvicorn reports 'Uvicorn running on http://127.0.0.1:8000' but the browser refuses, check that you did not type https. Python http.server: it serves the folder you launched it from, so a 404 there usually means you started it in the wrong directory.

When the address is right but the answer is wrong

Port 8000 is shared by enough frameworks that an old Laravel server can answer while you expect Django. The response headers give it away: Laravel sets a laravel_session cookie, and Django error pages name Django in their text.

If you only need a business website rather than a local project, We.Inc builds and previews the site in your browser, so there is no local server or port to manage.

How it works

  1. Start your framework's server and check the address it prints on startup.
  2. If startup fails with 'address already in use', find the old process with the commands below.
  3. Stop it, or start your server on 8001 using the command in the table.
  4. To open the app from another device, bind to 0.0.0.0 and allow the host in your framework.

Tips

  • Django's autoreloader runs two processes. If you kill only one, the port can stay busy, so stop the server with Ctrl+C rather than closing the terminal.
  • uvicorn main:app means the file main.py and the variable app inside it. A typo there stops startup before the port opens.
  • Laravel's artisan serve tries 8001, 8002 and so on when 8000 is taken, so check which port it actually reported.
  • A Python virtual environment that is not activated can start the wrong Django version, or fail on import, before anything listens.

Frequently asked questions

What runs on localhost:8000?

Usually a Python or PHP development server: Django runserver, Laravel artisan serve, uvicorn serving a FastAPI app, Gatsby's develop command or python -m http.server serving a folder of files.

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

Another process, often a previous runserver that did not exit, holds 8000. Find it with lsof -i :8000 on Mac or Linux or netstat -ano | findstr :8000 on Windows, stop it, then start again.

How do I open my Django app from my phone?

Run python manage.py runserver 0.0.0.0:8000, add your computer's local IP to ALLOWED_HOSTS in settings.py, then open http://<that IP>:8000 on a phone on the same network.

Why does FastAPI on localhost:8000 work but not from Docker?

uvicorn listens on 127.0.0.1 by default, which inside a container means the container only. Start it with --host 0.0.0.0 and publish the port with -p 8000:8000.

Can I use localhost:8000 in production?

No. Django, Laravel and Python's built-in servers are documented as development servers. In production run the app behind a proper application server and a web server or a managed host.

What runs on localhost:8001?

Often a second dev server moved off 8000, such as Laravel picking the next port. It is also the default of kubectl proxy, which serves the Kubernetes API at http://localhost:8001 while the command keeps running.

Related: localhost:5000, localhost:8080, localhost:3000, 404 Not Found.

Start for free or see all free tools. We.Inc is free to start, with no card needed. AI building is on paid plans from $20 a month.

More in Guides

Product

Who It's For

Features

Resources

Company

View Sitemap