I made two tests, using .NET to connect to Sql Server:
- I tried to connect to a local server which is on but the specified database does not exist. In this case it triggers a
SqlExceptionwith error number4060(cannot login with the specified user) - I tried to connect to a local server which process is stopped. In this case it triggers an
SqlExceptionwith error number-1(A network-related or instance-specific error occurred while establishing a connection to SQL Server).
In both cases it fails instantly, even though I specified 20 seconds in the connection string. In what situations will it wait the time I told it to wait?
It sounds like you’ve managed to connect – it’s not like you’re waiting for the network – but you’ve got authentication or authorization problems. I wouldn’t expect that to be part of a connection timeout. The purpose of a connection timeout is to handle network congestion – not to delay authentication failures.
EDIT: For the second case, the machine would presumably be actively refusing the connection. Again, that’s not network congestion – it’s not the kind of thing that connection timeouts are meant to handle.