Skip to main content
5000

Port 5000Development Server / Flask

TCP

Port 5000 is Flask's default development server port and a common alternative dev port to 3000. Docker Registry also uses port 5000. On macOS, Apple AirPlay Receiver occupies port 5000, causing conflicts with Flask development. Port 5000 should never be exposed publicly when used as a development server.

Port Number

5000

Protocol

TCP

Service

Flask / Generic Dev HTTP

Range

Unofficial

Description

Flask's built-in development server defaults to port 5000. It is single-threaded and not production-safe – use gunicorn or uvicorn behind nginx in production. Docker Registry API v2 also listens on port 5000. macOS Monterey+ enables AirPlay Receiver on port 5000 by default, which commonly causes 'Address already in use' errors for Flask developers. Disable AirPlay Receiver in System Settings > General > AirDrop & Handoff.

Security risks

  • 1Flask debug mode RCE: Flask with FLASK_DEBUG=1 on port 5000 exposes a Werkzeug interactive debugger. Anyone who reaches the debugger PIN prompt (or guesses the PIN) can execute arbitrary Python code on the server. Never run debug mode on 0.0.0.0.
  • 2Docker Registry without auth: Docker Registry on port 5000 with no authentication allows anyone to push malicious images (supply chain attack) or pull all your private images. Enable htpasswd or token-based auth.
  • 3macOS AirPlay conflict: Apple AirPlay Receiver on macOS 12+ grabs port 5000. Developers who switch to 0.0.0.0:5001 or disable AirPlay may accidentally leave the alternate port exposed. Use flask run --port 5001 --host 127.0.0.1 explicitly.

Firewall guidance

Never expose port 5000 to the internet. Flask dev server is single-threaded and has no security hardening. For Docker Registry: run behind Nginx with TLS and basic auth (registry:2 + htpasswd). For production Flask: use gunicorn/uvicorn behind Nginx on 443, never expose the WSGI server directly.

Diagnosis commands

Find what process is using port 5000 (macOS AirPlay vs Flask)

shell
lsof -i :5000

Test if Docker Registry is running on 5000 (returns {})

shell
curl -s http://localhost:5000/v2/ | jq .

Check if Flask is responding

shell
curl -s http://localhost:5000/ -o /dev/null -w '%{http_code}'

Usage examples

Port 5000 – Development Server / Flask
shell
flask run  # http://localhost:5000
python app.py  # Flask default
docker run -p 5000:5000 registry:2

Common services on this port

FlaskDocker RegistryMLflowGunicorn (dev)Apple AirPlay Receiver (macOS)Heroku local

Related ports

History

Port 5000 became Flask's default in 2010 when Armin Ronacher created the framework. Docker Registry adopted it in 2014. Apple's AirPlay Receiver claiming port 5000 in macOS Monterey (2021) caused widespread developer frustration.

FAQ

How do I fix 'Address already in use' on port 5000 on macOS?

macOS Monterey+ runs AirPlay Receiver on port 5000. Disable it: System Settings > General > AirDrop & Handoff > AirPlay Receiver: off. Or use a different port: flask run --port 5001.

Is Flask's dev server safe for production?

Absolutely not. It is single-threaded, has no request timeouts, no worker management, and Werkzeug debug mode can enable RCE. Production: gunicorn --bind 127.0.0.1:5000 --workers 4 app:app behind Nginx with TLS on 443.