Wednesday, April 04, 2012

Resolution for “No buffer space available (maximum connections reached?): JVM_Bind” issue

I hit this issue recently which occurred on only one windows 7 host. The error was caused by this hard to guess reason (http://support.microsoft.com/kb/196271). The default number of ephemeral TCP ports is 5000. Sometimes this number may become less if the server has too many active client connections due to which the ephemeral TCP ports are all used up and in this case no more can be allocated to a new client connection request resulting in the below issue (for a Java application):
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
    at java.net.Socket.bind(Socket.java:577)
    at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.bind(BaseSSLSocketImpl.java:95)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.bind(SSLSocketImpl.java:45)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:399)
    at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:123)
    at org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory.createSocket(EasySSLProtocolSocketFactory.java:183)
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
 



The resolution is to open the registry editor and locate the registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters and add a new entry as shown below:

Value Name: MaxUserPort
Value Type: DWORD
Value data: 65534
That’s it! Thanks to Daniel Baktiar for his post.

Update 6/14/2012:
Microsoft has a hot fix to resolve this issue for Win2K8 R2 and Win7: http://support.microsoft.com/kb/2577795

11 comments:

Anonymous said...

Thanks a lot. This fixed the problem.

rwatsh said...

you are welcome.

Micah said...

I got stuck with this issue on my PC but it was not convenient for me to restart the PC to apply the hotfix. Instead, after installing the hotfix (but not restarting) I was able to establish new TCP connections again by entering Services via services.msc at the cmd prompt, then restarting these two services:
DHCP Client
DNS Client

Zac Spitzer said...

alas this hotfix has been withdrawn

Anonymous said...

Thanks a lot, it really worked well !

Anonymous said...

I was experiencing this problem while testing a GWT application which was connecting to an SQL Server database. Running on Windows 7 with SQL Server 2008. This soultion fixed it for me.

Rafael Albani said...

Hi, i have a doubt about the type of base to use with this value. Is it Decimal or Hexadecimal?


BTW thanks for the great article!

Rafael Albani said...

Thanks @Watsh Rajneesh

Unknown said...

Thank you so much for your post. That works for me!

Lê Minh Hải said...

Thank so much.
It works

Anonymous said...

Worked for me as well. Very much thank you

Book Review: Spring Start Here: Learn what you need and learn it well

  Spring Start Here: Learn what you need and learn it well by Laurentiu Spilca My rating: 5 of 5 stars This is an excellent book on gett...