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
- Find and stop the process using the port
- Change the port in launchSettings.json or ASPNETCORE_URLS
- Disable AirPlay Receiver on macOS
Detailed fix by platform
Shell
- csharp
lsof -i :5000 netstat -ano | findstr :5000 # Windows dotnet run --urls http://localhost:5080
How to diagnose
- Owner — PID on the port
- 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:
Similar errors
- actively refused it HttpRequestException: No connection could be made because the target machine actively refused it (localhost:5001)
- bind() failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
- EADDRINUSE Error: listen EADDRINUSE: address already in use :::3000
Most viewed in .NET
- NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object
- FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies
- InvalidOperationException InvalidOperationException: Unable to resolve service for type 'X' while attempting to activate 'Y'
Other ways to find it
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026