C# DotNetCore Development: Manually Stopping the Kestrel Server
Posted: Tue Nov 02, 2021 9:26 am
When developing for DotNetCore you'll be running a local server or service on a specific local port number, for example port 52895.
Sometimes when trying to restart your server/service you'll see this error message:
NOTE: Depending on your particular debug setup that 52895 port will vary.
An easy way to fix this is to kill each an every DotNet process using this command in a PowerShell command prompt:
IMPORTANT: Before running any command from the internet make sure you understand what these commands do. In this case the command is killing all dotnet process which is perfectly acceptable for a development machine running, however running this command in a production environment would be totally acceptable.
Cheers Jussi
Sometimes when trying to restart your server/service you'll see this error message:
This means is a previous debug session is still running and that process is locking the 52895 port and hence the reason the start debug request fails.System.IO.IOException: Failed to bind to address http://127.0.0.1:52895: address already in use.
NOTE: Depending on your particular debug setup that 52895 port will vary.
An easy way to fix this is to kill each an every DotNet process using this command in a PowerShell command prompt:
Code: Select all
Get-Process -Name *dotnet* | Stop-Process
Cheers Jussi