OSError Errno 98 🐍 Python

OSError: [Errno 98] Address already in use

The port your server wants to bind is already taken by another process.

Seen on: Python

Meaning

Flask/Django/uvicorn dev servers left running, a previous crash, or another service on the same port. On macOS AirPlay Receiver uses port 5000.

Common causes

  • Old server process still running
  • Another service on the port (macOS AirPlay on 5000)
  • Socket in TIME_WAIT after a restart

⚡ Quick fix

  1. Find and stop the process: lsof -i :8000
  2. Use another port
  3. Set SO_REUSEADDR for your own socket servers

Detailed fix by platform

Python

  1. flask run --port 5001 / uvicorn app:app --port 8001

How to diagnose

  1. Port — Which port?
  2. Owner — lsof -i :PORT

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.