SQL Server- a network-related or instance-specific error occurred while establishing a connection to sql server
Error Details or symptoms: Can not connect to a SQL server and you get a error a network-related or instance-specific error occurred while establishing a connection to sql server
This error is seen in SQL Express installation as its installed a named instance by default with name of instance as Servername/SQLExpress.
Some other Errors Similar:
provider: named pipes provider, error: 40 – could not open a connection to sql server which is covered here.
provider: sql network interfaces, error: 26 – error locating server/instance specified which is covered here.
If we are connecting from Windows PC/Client to Windows server/SQL Server (server with SQL Server installed) and are getting the error above then we need to check following:
On Windows SQL Server if we are trying to connect to Named instance then:
Make sure the the Windows service called “SQL Server Browser” is started.
Make sure Windows Firewall is enabled for incoming port UDP 1434
Make sure Windows Firewall is enabled incoming port TCP 1433
Make Sure in SQL Server Configuration Manager that TCP/IP protocol is enabled and is set to to 1433(can be changed if needed)
Additionally, Make sure
Make sure your database engine is configured to accept remote connection. Right click on instance to go to properties page and make sure its enabled to accept remote connections.
If we are connecting to a named SQL Server instance, make sure that instance name in your connection string is right. Usually the format needed to specify the database server is machinename\instancename or in your connection string is right format with right instance name.