localhost:5000
The address of a development server on your own computer, on port 5000. Flask uses it by default, and on a Mac the AirPlay Receiver is already listening there.
Updated November 2026 · 3 min read
-
Written by
Andrian Valeanu
Founder of Pulsetic
-
Reviewed by
Ionut Caval
Technical reviewer
The short version: http://localhost:5000 is where Flask starts by default. On a Mac running macOS 12 or later, the AirPlay Receiver also listens on port 5000, so Flask reports "Address already in use", or the browser gets a 403 Forbidden from the wrong program. Run Flask on another port with flask run --port 5001, or turn the AirPlay Receiver off.
- Used by
- Flask, ASP.NET Core (Kestrel), MLflow, Docker registry
- Full address
http://localhost:5000- Conflict on Mac
- AirPlay Receiver (macOS 12 and later)
- Most common problem
- 403 Forbidden or "Address already in use" on a Mac
What is localhost:5000?
localhost:5000 is a program on your own computer listening on port 5000. For most people that program is Flask, the Python web framework, which has used 5000 as its development default from the start.
ASP.NET Core's Kestrel server falls back to http://localhost:5000 when no address is configured, MLflow's tracking UI uses it, and so does a local Docker registry.
The trouble started with macOS 12 (Monterey). Apple's AirPlay Receiver, which lets other devices play audio and video to a Mac, listens on ports 5000 and 7000 and is on by default. Every Flask tutorial written before that now fails on a Mac at its first step.
What runs on port 5000
These programs listen on port 5000 unless you tell them otherwise. The last column shows how to move each one to a different port.
| Program | How it starts | Change the port |
|---|---|---|
| Flask | flask run | flask run --port 5001, or app.run(port=5001) |
| ASP.NET Core (Kestrel) | dotnet run with no URL configured | dotnet run --urls http://localhost:5001, or launchSettings.json |
| MLflow | mlflow ui | mlflow ui --port 5001 |
| Docker registry | docker run -p 5000:5000 registry | Change the left-hand number: -p 5001:5000 |
| macOS AirPlay Receiver | On by default since macOS 12 | It cannot be moved. Turn it off in System Settings |
Why localhost:5000 will not load
- On a Mac, AirPlay has the port. Flask says
Address already in use. Port 5000 is in use by another program.Flask can also start without complaint while the browser reaches AirPlay over IPv6. You then see 403 Forbidden, with the response headerServer: AirTunes. - Nothing is running. The browser shows "localhost refused to connect". Flask stops when you close the terminal or when the app fails to import.
- Flask could not find your app.
Error: Could not locate a Flask applicationmeans the server never started. Name the fileapp.pyor pass--app. - Another dev server has the port. An earlier
flask run, or a .NET project, is still running. - You are opening it from another device or a container. Flask listens only on
127.0.0.1. Useflask run --host 0.0.0.0and publish the port in Docker. - You typed https. The Flask development server uses plain HTTP.
Find what is using port 5000
One command shows whether a program is listening on the port, and which one. No output means nothing is listening, and that is exactly when the browser says the connection was refused.
On Linux, ss -ltnp | grep :5000 gives the same answer. Add sudo on macOS or Linux to see programs owned by another user. Stopping a process ends whatever it was doing, so check what it is before you stop it.
How to fix it
On a Mac: 403 Forbidden or "Address already in use"
- Confirm it is AirPlay: run
curl -I http://localhost:5000. AServer: AirTunesheader is the AirPlay Receiver, not your app. - Easiest fix: use another port.
flask run --port 5001, then openhttp://localhost:5001. - Or turn the receiver off: System Settings, General, AirDrop & Handoff, then switch off AirPlay Receiver. On macOS 12 it is under System Preferences, Sharing.
- If a team shares the project, set the port in the project itself so nobody depends on a system setting.
If the page will not load
- Start the server with
flask runand keep the terminal open. - Read the output. An import error or "Could not locate a Flask application" means it never started.
- Open the address it prints:
Running on http://127.0.0.1:5000. - On Windows or Linux, find what holds the port with the commands in the section above.
From localhost to production
Flask's built-in server prints a warning for a reason: it is a development server, and it should not face real traffic. A deployed Flask app runs under a production server such as Gunicorn, behind a web server on ports 80 and 443. Nobody is watching a terminal there, so a crashed worker shows up as an error page for visitors.
To test a deployed address by hand, the free bulk URL status checker shows the status code and redirects for a list of URLs, and Is Website Down checks one from several countries. Neither can see localhost: like any service on the internet, they only reach public addresses.
Deployed it? Watch the public URL.
Pulsetic is website uptime monitoring. It cannot reach localhost, but once your app is live it checks the public URL from outside your network, confirms any failure from another region, then emails you.
10 monitors free, checked every 5 minutes, with email alerts on failure and recovery. No credit card.
Sources and further reading
The documentation and specifications this guide is written from.
Frequently asked questions
-
Why does localhost:5000 show 403 Forbidden on my Mac?
The AirPlay Receiver in macOS 12 and later listens on port 5000 and answers browser requests with 403. Your own app is not the one replying. Run your app on another port, or turn the AirPlay Receiver off in System Settings.
-
How do I change the Flask port?
Run
flask run --port 5001, set the environment variableFLASK_RUN_PORT=5001, or passport=5001toapp.run(). -
What is using port 5000 on my Mac?
Run
lsof -nP -iTCP:5000 -sTCP:LISTEN. If the command name isControlCe(Control Center), it is the AirPlay Receiver. -
Is it safe to turn off the AirPlay Receiver?
Yes. It only stops other Apple devices from playing audio or video to that Mac. Sending from the Mac to a TV or speaker still works, and you can switch it back on at any time.
-
Know when your live website stops answering.
2-minute setup · Cancel any time
-
No credit card needed