Failed to bind to address 🟪 .NET

System.IO.IOException: Failed to bind to address http://127.0.0.1:5000: address already in use

Kestrel can’t listen because another process (often a previous run of the same app) uses the port.

Seen on: .NET

Meaning

A previous dotnet run/watch still running, IIS Express, another app or Docker container on the port. On macOS, port 5000 is used by AirPlay Receiver.

Common causes

  • Previous instance still running (dotnet watch/debugger)
  • Another service on the port
  • macOS AirPlay Receiver on 5000/7000

⚡ Quick fix

  1. Find and stop the process using the port
  2. Change the port in launchSettings.json or ASPNETCORE_URLS
  3. Disable AirPlay Receiver on macOS

Detailed fix by platform

Shell

  1. csharp
    lsof -i :5000
    netstat -ano | findstr :5000   # Windows
    dotnet run --urls http://localhost:5080

How to diagnose

  1. Owner — PID on the port
  2. Config — URLs in launchSettings

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 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.