The total of live TCP connections is limited on operation system.

In your java application, if you experience java.net.SocketException: No buffer space available (maximum connections reached?), then you should check which process on the machine is consuming the resource.

First check the total connections on the machine, (execute the command in PowerShell)

netstat -anop tcp | measure

It will output the total count. Normally, the total count should be less than 200.

you can check the connection details

netstat -anop tcp

If one process (last column is the process ID) is hogging the connections, (in the following example 1696 is the process ID, you need to change it accordingly)

netstat -anop tcp | find `"1696`" | measure

Generally, in netstat output, you could see these TCP connection status, ESTABLISHED, TIME_WAIT, CLOSE_WAIT. If you wan to see the total connections established  by the specified process

netstat -anop tcp | find `"1696`" | find `"ESTABLISHED`" | measure


If the SocketException happens, then it will cause a large amount of CLOSE_WAIT connections. You can check the CLOSE_WAIT connections using the netstat commands below:

netstat -anop tcp | find `"1696`" | find `"CLOSE_WAIT`" | measure


You may need to run these commands on a daily base. If you see an obvious accumulation on total connections, especially on CLOSE_WAIT connections, please take capture the netstat output and contact us.

  • No labels