Today I have received this error on a remote server connecting from my local computer;
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 the SQL server is configured to allow remote connections. (provider: Named Pipes, Provider, error:40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2).
To fix this error goto start menu–> go to Microsoft Sql Server –> go to configurations folder and click on sql server configuration manager. check below image.
Expand Sql Native client 11.0 Configuration manager. In client protocols you will see TCP/IP, named Pipes,Via disabled, enable those
Expand Server Network Configuration In Protocols for Sql Server here Enable Shared,Named,TCP/IP
Expand Sql Native client 11.0 Configuration manager. In client protocols you will see TCP/IP, named Pipes,Via disabled, enable those and restart the Sql related services. Now the error fixed.
Resources
https://www.c-sharpcorner.com/article/resolve-error-40-could-not-open-a-connection-to-sql-server/