“Unable to Connect to SharePoint Database” – Detailed Troubleshooting Guide
The “Unable to connect to SharePoint database” error occurs when SharePoint cannot communicate with the SQL Server that hosts its databases. This issue can arise due to:
- SQL Server being offline or misconfigured.
- Incorrect database permissions for the SharePoint service account.
- Network connectivity issues between the SharePoint server and SQL Server.
- The SharePoint configuration database being in a problematic state (e.g., “Suspect” or “Offline”).
This step-by-step guide provides detailed troubleshooting instructions to identify and resolve the issue.
🔍 Step 1: Verify SQL Server is Running
If SQL Server is stopped or not accessible, SharePoint cannot connect to the database.
✅ How to Check SQL Server Status:
- Log in to the SQL Server where SharePoint databases are hosted.
- Open SQL Server Configuration Manager:
- Press
Win + R
, typeSQLServerManagerXX.msc
(replaceXX
with your SQL version), and press Enter.
- Press
- Under SQL Server Services, check the status of:
- SQL Server (MSSQLSERVER) – Ensure it is Running.
- SQL Server Browser – Should be Running if using named instances.
- If any service is Stopped, right-click it and select Start.
✅ Alternative: Check via PowerShell
Run the following command to check SQL Server status:
Get-Service -Name *SQL*
If SQL Server is stopped, start it using:
Start-Service -Name "MSSQLSERVER"
🔍 Step 2: Verify SQL Server is Reachable from SharePoint Server
Even if SQL Server is running, SharePoint may fail to connect due to network issues.
✅ How to Test Connectivity:
- Ping the SQL Server from the SharePoint Server:
- Open Command Prompt on the SharePoint Server.
- Run:
ping <SQL_Server_Name>
- If the request times out, there is a network issue preventing connection.
- Test SQL Connection via Telnet:
- Run:
telnet <SQL_Server_Name> 1433
- If it fails, SQL Server may not be listening on port 1433 or the port is blocked by a firewall.
- Run:
✅ How to Allow SQL Server in Windows Firewall:
- Open Windows Defender Firewall on the SQL Server.
- Click Advanced Settings → Inbound Rules.
- Ensure the following rules are Enabled:
- SQL Server (TCP-In) – Port 1433
- SQL Browser (UDP-In) – Port 1434 (for named instances)
- If missing, add a new rule for TCP Port 1433 and UDP Port 1434.
🔍 Step 3: Check SQL Server Authentication Mode
SharePoint requires Windows Authentication Mode for SQL Server access.
✅ How to Verify and Change Authentication Mode:
- Open SQL Server Management Studio (SSMS).
- Right-click the SQL Server instance → Properties.
- Go to the Security tab and check if Windows Authentication Mode is enabled.
- If it’s set to SQL Server and Windows Authentication Mode, change it to Windows Authentication Mode.
- Click OK, restart SQL Server, and test SharePoint connectivity again.
🔍 Step 4: Verify SharePoint Database Permissions
If the SharePoint service account lacks the correct database permissions, it won’t be able to connect.
✅ Steps to Check and Assign Proper Permissions:
- Open SQL Server Management Studio (SSMS).
- Expand Security → Logins.
- Find the SharePoint Farm Account (e.g.,
SPFarm
). - Right-click the account and select Properties.
- Under Server Roles, ensure it has:
- dbcreator
- securityadmin
- Under User Mapping, ensure the SharePoint databases have:
- db_owner assigned.
If permissions are missing, grant them and restart SharePoint/IIS.
🔍 Step 5: Check SharePoint Configuration Database State
If the SharePoint Configuration Database is corrupt or offline, SharePoint won’t be able to connect.
✅ Steps to Check Database Status:
- Open SQL Server Management Studio (SSMS).
- Run the following SQL query:
SELECT name, state_desc FROM sys.databases;
- If the SharePoint Configuration Database is in Suspect or Offline state, bring it online:
ALTER DATABASE SharePoint_Config SET ONLINE;
- If the database is still in Suspect mode, try the following:
ALTER DATABASE SharePoint_Config SET EMERGENCY; DBCC CHECKDB ('SharePoint_Config', REPAIR_ALLOW_DATA_LOSS); ALTER DATABASE SharePoint_Config SET ONLINE;
🔍 Step 6: Restart IIS and SharePoint Timer Service
If database connectivity has been restored, restart IIS and SharePoint services.
✅ Restart IIS:
iisreset /noforce
✅ Restart SharePoint Timer Service:
Restart-Service SPTimerV4
🔍 Step 7: Verify SharePoint Database Connection Strings
If the SQL Server name has changed or databases were moved, SharePoint may be using an incorrect connection string.
✅ How to Check:
- Open SharePoint Central Administration.
- Navigate to Manage Servers in Farm.
- Ensure the database server listed is correct.
- If incorrect, update it using PowerShell:
Set-SPDatabase -Identity "<DatabaseName>" -ServerInstance "<NewSQLServer>"
🔍 Step 8: Check Event Viewer for Errors
Event Viewer logs provide detailed error messages related to SQL Server connectivity.
✅ How to Check Event Logs:
- Open Event Viewer (
eventvwr.msc
). - Go to Windows Logs → Application.
- Look for SharePoint, SQL Server, or IIS errors.
- If an error message appears, take action based on the details provided.
🔍 Step 9: Test Database Connection with PowerShell
If you suspect a connection issue, test it with PowerShell.
✅ Run the Following PowerShell Script:
$SQLServer = "YourSQLServerName"
$Database = "SharePoint_Config"
$Connection = New-Object System.Data.SqlClient.SqlConnection
$Connection.ConnectionString = "Server=$SQLServer;Database=$Database;Integrated Security=True"
Try {
$Connection.Open()
Write-Host "Connected Successfully" -ForegroundColor Green
} Catch {
Write-Host "Connection Failed: $_" -ForegroundColor Red
} Finally {
$Connection.Close()
}
If the script fails, SQL Server might be unreachable or incorrectly configured.
🔍 Step 10: Final Checks and Server Restart
- Ensure all required services are running.
- Double-check firewall settings and network connectivity.
- Restart SQL Server, IIS, and the SharePoint Server as a last resort.