“Unable to contact the database” – A connection issue between SharePoint and the database.

Loading

“Unable to Contact the Database” in SharePoint – Causes, Troubleshooting, and Solutions

The “Unable to contact the database” error in SharePoint typically occurs when the SharePoint application fails to connect to its SQL Server database. This can happen due to various reasons, such as:

🔹 Database server downtime or network connectivity issues
🔹 Incorrect database credentials or authentication failures
🔹 Database corruption or read-only mode
🔹 SQL Server services not running
🔹 Firewall or security settings blocking SQL Server access

This error can cause site unavailability, prevent users from accessing SharePoint, and disrupt normal operations.


📌 Table of Contents

Common Causes of the Error
Step-by-Step Troubleshooting Guide
How to Fix SQL Server Connection Issues
Testing and Verifying the Fix


🚨 Common Causes of the “Unable to Contact the Database” Error

Before we begin troubleshooting, let’s look at the most frequent reasons why SharePoint fails to connect to the database.

1️⃣ SQL Server is Down or Not Responding

  • The SQL Server hosting the SharePoint databases may have stopped, crashed, or restarted.
  • Check if the SQL Server service is running.

2️⃣ Network Connectivity Issues

  • If the SharePoint server cannot communicate with the SQL Server due to network problems, firewalls, or incorrect DNS settings, the database connection will fail.

3️⃣ Incorrect SQL Server Instance Name or Connection String

  • If SharePoint is configured to connect to the wrong SQL Server instance or the connection string is misconfigured, this error may occur.

4️⃣ SQL Server Authentication and Permissions Issues

  • SharePoint uses a service account to connect to the database.
  • If this account lacks permissions or the password was changed but not updated, SharePoint won’t be able to access the database.

5️⃣ Database in Read-Only or Offline Mode

  • If the SharePoint database is marked as read-only, SharePoint won’t be able to write data, causing connectivity issues.

6️⃣ SQL Server Firewall or Security Restrictions

  • If the SQL Server firewall blocks incoming connections, SharePoint won’t be able to connect.

7️⃣ Corrupt SharePoint Configuration Database

  • If the SharePoint Config database is corrupt, SharePoint might not function properly.

🛠 Step-by-Step Troubleshooting Guide

Now, let’s go through step-by-step troubleshooting methods to identify and resolve the issue.


🔍 Step 1: Check if SQL Server is Running

Since SharePoint relies on SQL Server, the first step is to check whether the SQL Server is up and running.

✅ How to Check SQL Server Service Status:

  1. Log in to the SQL Server machine.
  2. Open Run (Win + R), type services.msc, and press Enter.
  3. Find SQL Server (MSSQLSERVER) or your specific SQL instance.
  4. If the service is Stopped, right-click and select Start.
  5. Restart the service if necessary.

Command to restart SQL Server using PowerShell:

Restart-Service -Name "MSSQLSERVER" -Force

Command to restart SQL Server using Command Prompt:

net stop MSSQLSERVER
net start MSSQLSERVER

🔍 Step 2: Verify Network Connectivity Between SharePoint and SQL Server

If SharePoint and SQL Server are hosted on different servers, check for network connectivity issues.

✅ How to Test Connectivity Using Ping and Telnet:

  1. Open Command Prompt on the SharePoint server.
  2. Run the following command to ping the SQL Server: ping [SQLServerName] If you get a request timeout or destination unreachable, there’s a network issue.
  3. Test if the SQL Server port (default is 1433) is open using Telnet: telnet [SQLServerName] 1433 If the connection fails, firewall rules or SQL Server settings may be blocking access.

✅ How to Allow SQL Server Traffic Through Firewall

  • Open Windows Defender Firewall.
  • Go to Inbound Rules → New Rule.
  • Allow connections on Port 1433 (for SQL Server).

🔍 Step 3: Check SharePoint Service Account Permissions in SQL Server

If the SharePoint service account does not have the required permissions, SharePoint won’t be able to access the database.

✅ How to Verify Service Account Permissions:

  1. Open SQL Server Management Studio (SSMS).
  2. Log in with an admin account.
  3. Go to Security → Logins.
  4. Find the SharePoint service account and ensure it has the following roles:
    • db_owner on all SharePoint databases.
    • securityadmin for user authentication.

SQL Query to Grant Permissions to SharePoint Account:

USE [master]
GO
ALTER SERVER ROLE sysadmin ADD MEMBER [DOMAIN\SharePointServiceAccount]
GO

🔍 Step 4: Check If the SharePoint Database is Read-Only or Offline

If the database is in Read-Only or Offline mode, SharePoint cannot access it.

✅ How to Check and Fix Read-Only Mode in SQL Server:

  1. Open SSMS and connect to SQL Server.
  2. Run the following SQL query to check the database state: SELECT name, state_desc FROM sys.databases
  3. If the database is in READ_ONLY mode, change it using: ALTER DATABASE [YourDatabaseName] SET READ_WRITE
  4. If the database is offline, bring it online using: ALTER DATABASE [YourDatabaseName] SET ONLINE

Restart IIS after making changes:

iisreset /noforce

🔍 Step 5: Check SQL Server Authentication Mode

SQL Server should allow both Windows and SQL Authentication.

✅ How to Enable Mixed Mode Authentication:

  1. Open SSMS and log in as an administrator.
  2. Right-click on the SQL Server instance → Select Properties.
  3. Go to the Security tab.
  4. Under Server authentication, select SQL Server and Windows Authentication mode.
  5. Click OK and restart the SQL Server service.

🔍 Step 6: Verify SharePoint Database Connection String

If SharePoint is pointing to the wrong SQL Server instance, it will fail to connect.

✅ How to Check and Update the Connection String:

  1. Open SharePoint Central Administration.
  2. Go to Manage Web Applications → Select the affected web app.
  3. Click on Manage Content Databases.
  4. Verify that the correct SQL Server instance is listed.
  5. If incorrect, update the settings.

Restart the SharePoint Timer Service to apply changes:

net stop SPTimerV4
net start SPTimerV4

Leave a Reply

Your email address will not be published. Required fields are marked *