Share via


Understanding the error “An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.”

This error message, which is associated with the Winsock error WSAENOBUFS and actually comes from Windows rather than SQL Server directly, has two well-understood root causes. However, it still stumps people today, probably because there is no single source which explains both root causes and offers solutions for both. Here is a description of the two common situations where you may see this error and quick solutions for each:

OS runs out of memory for TCP buffers

When a powerful client machine, especially one with lots of RAM, is running an x86 version of Windows, people use the /PAE switch in the c:boot.ini file to allow applications on that machine to be able to address the full range of memory. One other switch often used to give more memory to applications is the /3gb switch in the boot.ini file. The problem comes when these two are combined: the /3gb switch gives more memory to applications by reducing the amount of memory available to the OS. When it is used on a powerful machine where the applications require many OS resources, such as by opening many TCP connections, this can cause the OS to run out of memory for resources like TCP buffers. When that happens, Winsock throws the error WSAENOBUFS.

Solution: Remove the /3gb switch from c:boot.ini. The root problem in this case is memory pressure on the OS, so removing the /3gb switch will give more memory to the OS and will alleviate this problem.

OS runs out of available TCP “ephemeral” ports

When the client machine is opening many TCP connections and is running Windows Server 2003, Windows XP, or any earlier version of Windows, it may run out of TCP “ephemeral” ports. In Windows Server 2003, Windows XP, and earlier versions, Windows limits the number of available ephemeral ports to approximately 5000 across the machine. It is especially common to hit this problem for applications which do not use connection pooling.

Solution: To make more ephemeral ports available, follow the directions in this KB which describe how to create the MaxUserPort registry key: https://support.microsoft.com/kb/196271

 

Dan Benediktson
SQL Server Protocols
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights

Comments

  • Anonymous
    March 12, 2009
    PingBack from http://feeds.bscopes.com/2009/03/12/blog-sql-protocols/

  • Anonymous
    June 17, 2009
    This error also comes up as a consequence of poor handling of the asynchronous socket receiving operation, like: Sub ClientListening()        While True            ClientSocket.BeginReceive(SocketBuffer, 0, BufferSize, SocketFlags.None, AddressOf ReceiveCallback, Nothing)        End While End Sub

  • Anonymous
    August 11, 2009
    I'm using Opera 9.64, and if I leave my browser on the below page, it will start prompting for a username and password after five or fifteen minutes. This is incredibly annoying. http://blogs.msdn.com/sql_protocols/archive/2005/10/22/sql-server-2005-connectivity-issue-troubleshoot-part-i.aspx Otherwise, great blog, the information here is much appreciated.

  • Anonymous
    December 22, 2010
    Great post, a good and deep explanation of the problem. Anyway, I still get this exception, I changed the registry as stated to make bigger the MaxUserPort  value but it didn't work, same error... what else could it be? Thanks!

  • Anonymous
    March 24, 2011
    an opration on a socket could not be performed because the system lacked sufficient buffer space or because queue was full 192.168.20.2:8013

  • Anonymous
    July 05, 2015
    An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.