Tuesday, March 12, 2013

Debugging with Visual Studio Development Server fails: SocketException was unhandled

System.Net.Sockets.SocketException was unhandled
  Message="Only one usage of each socket address (protocol/network address/port) is normally permitted"
  Source="System"
  ErrorCode=10048
  NativeErrorCode=10048
  StackTrace:
       at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.Sockets.Socket.Bind(EndPoint localEP)
       at Microsoft.VisualStudio.WebHost.Server.Start()
       at Microsoft.VisualStudio.WebServer.WebServerApp.Main(String[] args)
This is probably because for some reason the last time you run debug, VSDS didn't stop running.

You can check which process is hung on the given port, and kill it with the following:

netstat -ano | findstr "5001"
Taskkill /F /PID