xConnect - Cannot Connect to SQL Server

May 8, 2019

My VM was cloned from another VM with Sitecore 9. If your's was too, you may have a similar situation with xConnect. If xdb is not working check the logs for:

            [Error] 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.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

The following StackOverflow article helped me solve my issue:
https://sitecore.stackexchange.com/questions/13024/xconnect-9-0-2-can-not-connect-to-sql-server

First verify your connection strings are setup correctly:
[xConnect Website Root]\App_Config\ConnectionStrings.config

Then open up SQL Server Management Studio and do the following:

  1. Expand Databases -> sitecore9_Xdb.Collection.ShardMapManager -> Tables
  2. Right click _ShardManagement.ShardsGlobal
  3. Select Edit Top 200 Rows
  4. Change the value in the ServerName column on each row to your server name
  5. Restart IIS