Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached

I got error sometime like :
Timeout expired. The timeout period elapsed prior to obtaining a
connection from the pool. This may have occurred because all pooled
connections were in use and max pool size was reached
Jinal_ShahAsked:
Who is Participating?
 
Pratima PharandeCommented:
are you using SQL DataReader ?? if yes check are you closing the data reader
and close all the open connections from code

0
 
Pratima PharandeCommented:
SqlConnection conn = new SqlConnection(myConnectionString);

      try

      {

            conn.Open();

            doSomething(conn);

      }

      finally

{

            conn.Close();                

      }
0
 
Pratima PharandeCommented:
Short term fixes

What if you discovered the connection pooling issue in production and you cannot take it offline to troubleshoot? Turn pooling off. Even though your app will take a performance hit, it shouldn't crash! Your memory footprint will also grow. What if it doesn't crash all that often, and you don't want to take a performance hit? Try this:


conn = new SqlConnection();

try

{

  conn.ConnectionString = "integrated security=SSPI;SERVER=YOUR_SERVER;DATABASE=YOUR_DB_NAME;Min Pool Size=5;Max Pool Size=60;Connect Timeout=2;";     // Notice Connection Timeout set to only two seconds!

  conn.Open();

}

catch(Exception)

{

  if (conn.State != ConnectionState.Closed) conn.Close();

  conn.ConnectionString = "integrated security=SSPI;SERVER=YOUR_SERVER;DATABASE=YOUR_DB_NAME;Pooling=false;Connect Timeout=45;";

  conn.Open();

0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Pratima PharandeCommented:
0
 
deightonprogCommented:
run
sp_who
in SQL server query window to check how many connections are open.

Quite likely you have failed to close a connection

make sure connections are .disposed when no longer needed, or at least .closed
0
 
Jinal_ShahAuthor Commented:
Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.