Tcpip error: Request failed due to all such ports being in use

Today my machine stopped being able to access the internet. I can still access some local network resources. When I looked in the error log I saw following tcpip warning:

A request to allocate an ephemeral port number from the global UDP port space has failed due to all such ports being in use.

I ran netstat -anob and in the output DNScache is listed thousands of times (starting from port 50000 up to 65536).

netstat output

This is the second time that this has happened to me. Killing the DNSClient process based on the instructions found here did work, but I would like to figure out what is causing this problem.

Update: When this problem happens I am still able to get online with programs that used DNS to resolve a hostname before the problem started. For example, I am able to continue chatting with friends with Pidgin. I am also able to connect to websites directly using the IP address.


Solution 1:

I figured it out! It was the HealthAlertsSvc (Windows Server Health Service). It looks like the health service on my Windows Home Server 2011 machine crashed, and that revealed a bug in the client side HealthAlertsSvc where it wouldn't release the UDP ports correctly.

To double check that this was the case. I disabled the service on the server side and on my desktop. As soon as I re-enabled the service on my desktop the number of UDP connections that were left open started to slowly grow. After I re-started the service on the server, a large number of the UDP connections were immediately released, and the list no longer grew in size.