Intermittent site outages with SQL server connection errors


If you are experiencing site outages that occur intermittently but regularly and which resolve on their own, check your server logs for the following error:

System.Data.SqlClient.SqlException (0x80131904): 
A network-related or instance-specific error occurred while establishing a connection to
SQL Server. The server was not found or was not accessible. Verify that the instance name
is correct and that SQL Server is configured to allow remote connections. (provider:
Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
System.ComponentModel.Win32Exception (0x80004005): The network path was not found



Verify that your SQL Server instance has no downtime corresponding with the site downtime using your SQL server logs. If there is no server downtime corresponding with site downtime, this issue could be caused by your database backup. Server backups, especially in larger instances, are incredibly I/O-intensive and, if not carefully managed, can cause downtime during your server's maintenance period.

Note: If there is server downtime corresponding with site downtime, the SQL server will need to be examined separately by your DBA.

To confirm the issue, follow the steps below:

  1. Run the following SQL query in your IDE of choice to check whether you had previous backups that overlap your site downtime:
    SELECT bs.server_name AS ServerName,
    CASE bs.compatibility_level
    WHEN 90 THEN 'SQL Server 2005'
    WHEN 100 THEN 'SQL Server 2008 or SQL Server 2008 R2'
    WHEN 110 THEN 'SQL Server 2012'
    WHEN 120 THEN 'SQL Server 2014'
    END AS ServerVersion,
    bs.database_name AS DatabseName,
    CASE bs.type
    WHEN 'D' THEN 'Full'
    WHEN 'I' THEN 'Database Differential'
    WHEN 'L' THEN 'Log'
    WHEN 'F' THEN 'File or filegroup'
    WHEN 'G' THEN 'Differential file'
    WHEN 'P' THEN 'Partial'
    WHEN 'Q' THEN 'Differential partial'
    END AS BackupType,
    bs.backup_start_date AS BackupStartDate,
    bs.backup_finish_date AS BackupFinishDate,
    CASE bmf.device_type
    WHEN 2 THEN 'Disk'
    WHEN 5 THEN 'Tape'
    WHEN 7 THEN 'Virtual device'
    WHEN 105 THEN 'A permanent backup device'
    ELSE 'Other Device'
    END AS DeviceType,
    bmf.physical_device_name AS PhysicalDevice,
    bs.backup_size/(1024*1024) AS [BackupSize(MB)],
    bs.compressed_backup_size/(1024*1024) AS [ConmpressedBackupSize(MB)]

    FROM msdb.dbo.backupset bs
    INNER JOIN msdb.dbo.backupmediafamily bmf
    ON bs.media_set_id = bmf.media_set_id
    ORDER BY bs.backup_start_date ASC


  2. Check for overlaps between your outages and maintenance windows, paying special attention to the backup size and start/finish date/times:

If there are overlaps, it's likely that server maintenance processes are related to the site outages. In that case, it is recommended to consult with your DBA to adjust your backup schedule and review the maintenance processes. For further information, please refer to Microsoft's Troubleshooting SQL Server backup and restore operations article. 



Please sign in to leave a comment.