title: SQL Server: Max pool size was reached
body: <p>I'm observing following errors while connecting SQL Server from c# application whenever application pool get recycled. I've checked when this errors received there was only 20 connection open in the database despite actual limit is 200(that I set in web.config).</p>
  
  <p>Also, connections are properly closed in code so that would not be an issue. Please note that it doesn't occur every time when pool recycled but happens during a day when we have traffic on our system.</p>
  
  <blockquote>
    <p>System.InvalidOperationException: 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.    at
    System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
    owningConnection, TaskCompletionSource<code>1 retry, DbConnectionOptions
    userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&amp;
    connection)    at
    System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
    outerConnection, DbConnectionFactory connectionFactory,
    TaskCompletionSource</code>1 retry, DbConnectionOptions userOptions)    at
    System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
    outerConnection, DbConnectionFactory connectionFactory,
    TaskCompletionSource<code>1 retry, DbConnectionOptions userOptions)    at
    System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource</code>1
    retry)    at
    System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1
    retry)    at System.Data.SqlClient.SqlConnection.Open()    at
    System.Data.SqlClient.SqlConnection.Open()</p>
  </blockquote>