localhost:5000

Port 5000 has two major occupants — Flask (Python's lightweight web framework) and ASP.NET Core (Microsoft's cross-platform web framework). They have nothing in common except this port number, which creates confusion when people search for help and get answers for the wrong framework.

To make things worse, if you're on macOS Monterey or later, Apple's AirPlay Receiver quietly grabs port 5000 at boot, preventing both Flask and .NET from using it. This has been the single most common "why won't my Flask app start" question since 2021.

Quick Access: Open localhost:5000

The macOS AirPlay Conflict (Fix This First)

If you're on macOS and getting "Address already in use" when starting Flask or .NET on port 5000, it's almost certainly AirPlay Receiver. Apple enabled it by default starting in macOS Monterey, and it listens on both ports 5000 and 7000.

To disable it: Go to System Settings → General → AirDrop & Handoff (or System Preferences → Sharing on older macOS) and uncheck AirPlay Receiver. Port 5000 is immediately freed.

If you actually use AirPlay and don't want to disable it, just run your app on a different port (5001, 8000, etc.).

Flask on Port 5000

Flask is Python's minimalist web framework — "micro" in philosophy, not in capability. The built-in development server defaults to port 5000:

# Minimal Flask app (app.py)
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello, World!'

# Run it
flask run
# Or:
python -m flask run
# Or in the code:
app.run(debug=True)

# Output: Running on http://127.0.0.1:5000

Change Flask's Port

# Command line
flask run --port 8000

# In code
app.run(port=8000, debug=True)

# Environment variable
export FLASK_RUN_PORT=8000
flask run

# Listen on all interfaces (access from other devices)
flask run --host 0.0.0.0

Flask's built-in server is single-threaded and development-only. For production, use Gunicorn or uWSGI behind Nginx:

# Production with Gunicorn
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app

ASP.NET Core on Port 5000

Microsoft's .NET web framework also defaults to port 5000 for HTTP (and 5001 for HTTPS):

# Create and run a .NET web app
dotnet new web -o myapp
cd myapp
dotnet run

# Output: Now listening on http://localhost:5000
#         Now listening on https://localhost:5001

Change .NET's Port

// launchSettings.json (in Properties folder)
{
  "profiles": {
    "myapp": {
      "applicationUrl": "https://localhost:7001;http://localhost:7000"
    }
  }
}

// Or in appsettings.json:
{
  "Urls": "http://localhost:8000"
}

// Or via command line:
dotnet run --urls "http://localhost:8000"

Telling Flask and .NET Apart

If something's running on 5000 and you're not sure which framework it is, check the response headers. Flask typically returns Server: Werkzeug/x.x.x, while ASP.NET Core returns Server: Kestrel. Or just check your process list:

# What's on port 5000?
lsof -i :5000    # macOS/Linux
netstat -ano | findstr "5000"   # Windows

Other Things on Port 5000

Beyond Flask and .NET, you'll occasionally encounter:

  • Docker Registry — a self-hosted Docker image registry defaults to 5000
  • Synology NAS — DSM web interface uses 5000 (HTTP) and 5001 (HTTPS)
  • UPnP — some devices use 5000 for Universal Plug and Play

Troubleshooting

"Address already in use" on macOS: AirPlay Receiver. See fix above.

Flask shows "Serving Flask app" but page doesn't load: Flask defaults to 127.0.0.1, which means only connections from your own machine work. If you're trying to access from a phone or another computer, run with --host 0.0.0.0.

.NET app starts but you can't connect: Check if it's binding to localhost vs 0.0.0.0. Also verify the HTTP vs HTTPS port — .NET defaults to redirecting HTTP to HTTPS, which may confuse you if you're accessing http://localhost:5000 and it silently redirects to https://localhost:5001 with a certificate warning.