Originally published at SQL & Cloud Lab .
This post was drafted with AI assistance.
"Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool." If you have seen this error in a .NET application, the database is usually fine; the application has run out of pooled connections. Understanding how pooling works makes it easy to find the real cause.
How connection pooling works
Opening a physical connection to SQL Server is expensive: network round trips, authentication and session setup. So Microsoft.Data.SqlClient keeps a pool of open connections and reuses them.
When you call Open() , you get an existing connection from the pool if one is free.
When you call Close() or Dispose() , the connection goes back to the pool instead of being closed.
There is a separate pool for each distinct connection string in each process.
By default a pool holds up to 100 connections ( Max Pool Size ).…