The server was not found or was not accessible. NET Framework Exception (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. When the exception is thrown, the innermost message is:
This behavior is consistent with both Open and OpenAsync. is the DNS cache being flushed and is resolution being reattempted? I don't know enough about how DNS queries are cached by the various OSes to make an educated guess here. It's also not clear to me that this even gives you resiliency to DNS issues. However, this seems like a bad behavior to wait so long for a problem that is unlikely to repair itself in a relatively short time (order of seconds). We could also mitigate this with a circuit breaker pattern. Note that we use the non-async APIs on SqlConnection so this could perhaps be improved by switching to, say, OpenAsync (haven't tested). 30 seconds is the value we set for Connection Timeout in our connection string. My web application started to queue requests (something we almost never see) due to so many requests taking 30 seconds to fail opening a connection. I noticed this problem during the Azure DNS outage on May 2, 2019. This contrasts with the behavior of HttpClient which fails almost immediately when trying to send an HTTP request to a bad DNS name.
When the Data Source (server DNS) in a SQL Server connection string is a DNS name that can't resolve, opening the SqlConnection takes the entire Connection Timeout to throw an exception.