Kevindt12
Kevindt12

Reputation: 119

SQL Error 26 Error Locating Server/Instance Specified

I'm trying to find out this problem the whole day. I get an error on a website I'm trying to publish :

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

I have done everything that other threads have said. Like open firewall ports (To make my life easy i just disabled it) Set up TCP/IP in SQL Server Configuration Manager, also done that set it to 1433. Yet there is something weird there just to say maybe that is it but im not sure on each IP it says Enabled: No

Just thought that was weird but yea. And yes restarted SQL server service like 20 times now. My instance name is SQLSERVER2016 I don't know if that was a smart idea.

I think it's the connection string since in SSMS I can connect to the instance without a problem but I'm not sure I'm still very new to SQL. I've set everything to connect with the Administrator account. So here are my connection strings.

<add name="DefaultConnection" 
     connectionString="Data Source=KEVIN-WEBSERVER\SQLSERVER2016;Initial Catalog=BetaUsersDatabase;Trusted_Connection=yes;MultipleActiveResultSets=true;" 
     providerName="System.Data.SqlClient" />
<add name="ForumDatabase" 
     connectionString="Data Source=KEVIN-WEBSERVER\SQLSERVER2016;Initial Catalog=BetaForumDatabase;Trusted_Connection=yes;MultipleActiveResultSets=true;" 
     providerName="System.Data.SqlClient" />

I've also tried some other variations but they all did not work I have not kept them sorry. But yes, I'm using SQL Server 2016 Express.

Upvotes: 0

Views: 8666

Answers (1)

sepupic
sepupic

Reputation: 8687

You have a named instance, KEVIN-WEBSERVER\SQLSERVER2016, and the named instance by default is listening on some dynamic port, that of course is not 1433.

In order to connect to a named instance you should provide IP,port or you can use SQL Server Browser and pass in your instance name.

Your connection string does the latter, i.e. you pass in only the instance name, so your SQL Server Browser must be started.

Here Overview of the SQL Server Browser service you find more about SQL Server Browser

Upvotes: 2

Related Questions