Ubuntu: How to Kill DotNet Runtime
Sometimes, a a dotnet runtime closes without releasing a listening port.
This will prevent it from restarting, because the port is already in use.
While running the dotnet run if you stop the server using ctr + z then it Ctrl+z sends the SIGTSTP (Signal Tty SToP) signal to the foreground job but don't actually stop the running kestrel server, so you have to mannualy end the process of the kestrel server.
SOLLUTION Only use ctr + c to stop the kestrel server, actually its even displayed on the shell while you run dotnet run.
To manually kill the kestrel server, use this command to get the running process that is listening on port 5000:
sudo lsof -iTCP -sTCP:LISTEN -P | grep :5000
Then, kill the process with:
sudo kill -9 PID