Symptoms
Unable to register SQL service instance with the following error message being displayed:
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)"
Diagnoses
This error is quite clear indication of inability to connect to SQL server either due to lack of network connectivity (firewall issues) or permissions. But before even checking these things just make sure that you specified correct SQL server name and (in case named SQL instance is being used) instance name. In case you are sure that SQL server details specified are correct but service instance still cannot be register try to put K2 outside of the picture by testing connectivity to SQL server from K2 server. You may just try to connect to SQL using SQL Server Management Studio (in case it is installed on K2 server) or follow these instructions:
Test remote SQL connectivity EASILY!
In case connection to SQL fails using these tests then you just confirmed that issue lies outside of K2 and caused by problems with connectivity from the K2 server to the SQL server. In this case you may want to check with your SQL server administrator to make sure that correct network ports are open on the SQL server and the user you are using to establish connection (e.g. K2 service account) has correct permissions.
This article might help here:
Tips and Tricks to fix SQL Connectivity Issues
Resolution
Verify that proper SQL server name / named instance name is specified during SQL service instance registration. Make sure that SQL server is up and running, K2 service account has correct permissions on a SQL server side and communication over required network ports is allowed between K2 and SQL servers.