T The Triage ManualTechnical Guides for IT Emergencies
P2 · Windows Server

Database Connection Errors — Application Unable to Establish or Maintain Database Connectivity Due to Pool Exhaustion, Network, or Server Faults

Database connection errors occur when applications cannot establish or sustain connections to backing databases, causing service degradation or complete outage. Root causes include exhausted connection pools, misconfigured connection strings, network-layer failures between application and database hosts, or database server resource exhaustion. Resolution requires identifying whether the fault lies in the application tier, network path, or database server, then addressing the specific bottleneck through pool configuration, credential correction, or server-side connection management.

Indicators

Likely causes

Diagnostic steps

  1. Review application logs for the exact error message returned when a connection attempt fails, noting the timestamp, error code, and any stack trace. Check Windows Event Viewer > Application log for related errors.
    Identifies whether the failure is a timeout, authentication error, connection refused, or pool exhaustion, which determines the diagnostic path.
  2. Test basic network connectivity from the application host to the database host and port: - Windows: `Test-NetConnection -ComputerName <db-host> -Port <db-port>` - Linux: `telnet <db-host> <db-port>` or `nc -zv <db-host> <db-port>`
    Confirms whether a TCP connection can be established, ruling out network-layer or firewall-layer failures.
  3. Check current connection count against configured maximum on the database server: - SQL Server: `SELECT COUNT(*) AS connections FROM sys.dm_exec_connections;` and `SELECT @@MAX_CONNECTIONS;` - MySQL: `SHOW STATUS LIKE 'Threads_connected';` and `SHOW VARIABLES LIKE 'max_connections';` - PostgreSQL: `SELECT count(*) FROM pg_stat_activity;` and `SHOW max_connections;`
    Determines whether the database server is at or near its connection limit, which would cause new connection attempts to be rejected.
  4. Validate the connection string in the application configuration, confirming host, port, database name, username, and password are correct. Test with a direct database client from the application server: - SQL Server: `sqlcmd -S <server> -U <user> -P <password> -d <database> -Q "SELECT 1"` - MySQL: `mysql -h <host> -u <user> -p<password> -e "SELECT 1"` - PostgreSQL: `psql -h <host> -U <user> -d <database> -c "SELECT 1"`
    Rules out misconfiguration or stale credentials as the root cause of connection failures.
  5. Check database server error logs and system resource utilisation: - SQL Server: Check SQL Server Error Log and `SELECT * FROM sys.dm_os_wait_stats ORDER BY wait_time_ms DESC;` - Windows: Performance Monitor for CPU, memory, disk I/O - Check for OOM events in Windows Event Log > System
    Identifies whether the database server itself is unhealthy and needs to be restarted or scaled before connections can succeed.
  6. Identify connection-consuming queries or blocked sessions: - SQL Server: `SELECT * FROM sys.dm_exec_requests WHERE blocking_session_id <> 0;` - PostgreSQL: `SELECT * FROM pg_stat_activity WHERE state != 'idle' ORDER BY query_start;`
    Identifies long-running or blocked queries that may be holding connections and preventing pool recycling.

Resolution path

Prevention

Tools

References

databaseconnectivityconnection-pooltimeoutauthenticationnetworksql-servermysqlpostgresqlincident-responsebackendapplication-tier