Hi @Tom Haepers ,
Thanks for reaching out.
This can happen when Kestrel tries to start on the default ASP.NET Core HTTP port, 5000, but another process is already using it. In a published app, that port may be coming from the ASP.NET Core defaults, ASPNETCORE_URLS, DOTNET_URLS, appsettings.json, or code in Program.cs such as UseUrls() or ListenLocalhost(). launchSettings.json is mainly used by Visual Studio or dotnet run, so it usually does not affect a published .exe directly.
Open Command Prompt or PowerShell as Administrator and check what is using the port:
netstat -ano | findstr :5000
The last column is the PID. You can look it up with:
tasklist /FI "PID eq <PID>"
or check the Details tab in Task Manager. If netstat shows “Access is denied”, the terminal likely was not opened with administrator rights.
If the process using port 5000 is not needed, stop it. Otherwise, run your app on another port:
YourApp.exe --urls "http://127.0.0.1:5050"
or set it with an environment variable. In Command Prompt:
set ASPNETCORE_URLS=http://127.0.0.1:5050
YourApp.exe
In PowerShell, use:
$env:ASPNETCORE_URLS="http://127.0.0.1:5050"
.\YourApp.exe
If this is hosted in IIS, also make sure the deployed app is not carrying over a hardcoded development URL. Check Program.cs, appsettings*.json, web.config, and server-level environment variables for anything pointing to 127.0.0.1:5000.
With IIS, the app should normally be started through the ASP.NET Core Module. Manually launching the executable is useful for troubleshooting, but if IIS is already starting the app, running it again can create another instance and cause the same conflict.
Hope this helps! If my answer was helpful, I would greatly appreciate it if you could follow the instructions here so others with the same problem can benefit as well.