Visual Studio - Unable to launch the IIS Express Web server

I run into this error on occasion, more often on old websites.

Failed to register URL "http://localhost:{PortNumber}" for site {SiteName} application "/". Error description: The process cannot access the file because it is being used by another process. (0x80070020)

My first go-to, if it isn't too much trouble, has been to restart the computer. It's quick, easy & often unlocks any files a different process is using.

Another method I had recent luck with is to try and restart the WinNAT service.

net stop winnat

net start winnat

This has fixed my issues even after restarting Windows wouldn't. Restarting WinNAT will cause Windows to release ports that it's locking from use.

Matt Ferderer

Software engineer who spends his time learning about building teams, project management, software architecture, C#, .NET Core, Blazor, JavaScript, TypeScript, Azure, user experience, web security, and performance.