Home
%3CLINGO-SUB%20id%3D%22lingo-sub-334029%22%20slang%3D%22en-US%22%3EConnectivity%20Problems%20Caused%20by%20Issues%20in%20SQL%20Server%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-334029%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Jan%2027%2C%202019%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EVery%20frequently%20problems%20connecting%20to%20SQL%20Server%20originate%20from%20network-related%20or%20authentication%20issues.%20Here%20are%20examples%20of%20connectivity%20timeout%20errors%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ETimeout%20expired.%20The%20timeout%20period%20elapsed%20prior%20to%20completion%20of%20the%20operation%20or%20the%20server%20is%20not%20responding.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESystem.Data.SqlClient.SqlException%20(0x80131904)%3A%20Connection%20Timeout%20Expired.%20The%20timeout%20period%20elapsed%20while%20attempting%20to%20consume%20the%20pre-login%20handshake%20acknowledgement.%20This%20could%20be%20because%20the%20pre-login%20handshake%20failed%20or%20the%20server%20was%20unable%20to%20respond%20back%20in%20time.%20The%20duration%20spent%20while%20attempting%20to%20connect%20to%20this%20server%20was%20-%20%5BPre-Login%5D%20initialization%3D23%3B%20handshake%3D14979%3B%20---%26gt%3B%20System.ComponentModel.Win32Exception%20(0x80004005)%3A%20The%20wait%20operation%20timed%20out%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESystem.Data.SqlClient.SqlException%20(0x80131904)%3A%20Timeout%20expired.%20The%20timeout%20period%20elapsed%20prior%20to%20completion%20of%20the%20operation%20or%20the%20server%20is%20not%20responding.%20---%26gt%3B%20System.ComponentModel.Win32Exception%20(0x80004005)%3A%20The%20wait%20operation%20timed%20out%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EConnection%20Timeout%20Expired.%20The%20timeout%20period%20elapsed%20while%20attempting%20to%20consume%20the%20pre-login%20handshake%20acknowledgement.%20This%20could%20be%20because%20the%20pre-login%20handshake%20failed%20or%20the%20server%20was%20unable%20to%20respond%20back%20in%20time.%20The%20duration%20spent%20while%20attempting%20to%20connect%20to%20this%20server%20was%20-%20%5BPre-Login%5D%20initialization%3D21036%3B%20handshake%3D0%3B%20(Microsoft%20SQL%20Server%2C%20Error%3A%20-2)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3EHere%20are%20Common%20Culprits%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ENetwork%20Connection%20Issues%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EKerberos%20issues%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3EDNS%20issues%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CUL%3E%0A%3CLI%3ESQL%20Protocol%20issues%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20more%20information%2C%20see%20this%20%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Fhelp%2F4009936%2Fsolving-connectivity-errors-to-sql-server%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20excellent%20SQL%20connectivity%20Troubleshooter%20%3C%2FA%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CU%3ESQL%20Server%20Contributors%20to%20Connectivity%20Problems%3C%2FU%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3EThere%20is%20small%20number%20of%20issues%20on%20SQL%20Server%20Database%20engine%20side%20that%20can%20lead%20to%20connectivity%20problems.%20Here%20is%20the%20list.%20This%20is%20to%20help%20with%20what%20to%26nbsp%3Blook%20for%20when%20a%20connectivity%20problem%20is%20raised.%20But%20as%20a%20general%20practice%20start%20with%20network%20problems%201.%20Scheduler%20problems%20(non-yielding%2C%20deadlocked%2C%20etc)%26nbsp%3B%20-%20check%20Errorlogs%202.%20Running%20out%20of%20worker%20threads%20-%20check%20Perfmon%20for%26nbsp%3BSQLServer%3AWait%20Statistics-%26gt%3BWait%20for%20the%20worker%20(avg%20wait%20time%2C%20waits%20in%20progress)%2C%20THREADPOOL%20wait%20type%20in%20DMVs%20(wait%20durations%20say%20over%2010%20seconds).%20Typical%20causes%20for%20running%20out%20of%20worker%20threads%20are%20either%20long%20waits%20(blocking%2C%20latch%20waits%2C%20I%2FO%20waits%2C%20huger%20parallel%20queries)%2C%20or%20a%20very%20large%20number%20of%20long-running%20queries.%20%3CBR%20%2F%3E3.%20Sp_reset_connection%20delays%20-%20much%20more%20rare%20-%20check%20sp_reset_conneciton%20times%20in%20a%20trace%204.%20Database%20unavailable%20(including%20AG%20is%20not%20online%20or%20resolving)%205.%20Out%20of%20Memory%20-%20low%20virtual%20memory%20on%20machine%20or%20processes%20are%20being%20paged%20out.%20Check%20Perfmon%20counters%20(Memory-%26gt%3BAvailable%20MBytes)%20for%20RAM%20exhaustion%20and%20thus%20low%20virtual%20memory.%20For%20Processes%20being%20paged%20out%2C%20look%20at%20Perfmon%20(Process-%26gt%3BWorking%20Set)%20and%20see%20if%20there%20is%20a%20sudden%20drop%20of%20most%2Fall%20processes'%20working%20sets%20on%20the%20system.Namaste%20Joseph%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-334029%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20Jan%2027%2C%202019%20Very%20frequently%20connectivity%20problems%20to%20SQL%20Server%20are%20issues%20originating%20from%20network-related%20or%20authentication%20issues.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-334029%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Econnectivity%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

First published on MSDN on Jan 27, 2019

 

Very frequently problems connecting to SQL Server originate from network-related or authentication issues. Here are examples of connectivity timeout errors:

    • Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

 

    • System.Data.SqlClient.SqlException (0x80131904): Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=23; handshake=14979; ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

 

    • System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

 

    • Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=21036; handshake=0; (Microsoft SQL Server, Error: -2)



Here are Common Culprits:

    • Network Connection Issues

 

    • Kerberos issues

 

    • DNS issues

 

    • SQL Protocol issues



For more information, see this excellent SQL connectivity Troubleshooter

SQL Server Contributors to Connectivity Problems

There is small number of issues on SQL Server Database engine side that can lead to connectivity problems. Here is the list. This is to help with what to look for when a connectivity problem is raised. But as a general practice start with network problems



1. Scheduler problems (non-yielding, deadlocked, etc)  - check Errorlogs
2. Running out of worker threads - check Perfmon for SQLServer:Wait Statistics->Wait for the worker (avg wait time, waits in progress), THREADPOOL wait type in DMVs (wait durations say over 10 seconds). Typical causes for running out of worker threads are either long waits (blocking, latch waits, I/O waits, huger parallel queries), or a very large number of long-running queries.
3. Sp_reset_connection delays - much more rare - check sp_reset_conneciton times in a trace
4. Database unavailable (including AG is not online or resolving)
5. Out of Memory - low virtual memory on machine or processes are being paged out. Check Perfmon counters (Memory->Available MBytes) for RAM exhaustion and thus low virtual memory. For Processes being paged out, look at Perfmon (Process->Working Set) and see if there is a sudden drop of most/all processes' working sets on the system.

Namaste

Joseph