My .Net Web API program keeps showing me the same error whenever I try to debug it. Here is the error:
Exception has occurred: CLR/System.IO.IOException
An unhandled exception of type 'System.IO.IOException' occurred in System.Private.CoreLib.dll: 'Failed to bind to address http://127.0.0.1:5082: address already in use
I'm programming on Macbook M1 and VS Code btw.
It didn't help changing the port number.
I run it by typing "dotnet run" on terminal, after it started running I select the .NET Core Launch(web) configuration and click the run button on VS Code Run and Debug component. If I click this button without starting the program or just click Run->Start Debugging, it can't find the localhost on that port number. However, running the program on Swagger with "dotnet watch run" does not cause any problem, it works perfectly.
I've checked if that port number really in use by typing "lsof -i 5082" before running the program but nothing showed up. I feel like "dotnet run"+"Run and Debug button" combination tries to run the program 2 times but I couldn't find the proper way to do it.