provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified No fix? - sql-server

I recently added a second site to my server. That site gives me the dreaded:
System.Data.SqlClient.SqlException: 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 no idea why I am getting this. I've gone through this and this to no avail. This is a new MVC4 application I have at beta.vinformative.com in IIS 7. The other site is a MVC3 site at vinformative.com. It is running fine. Both of their databases have the exact same connection string and they are both on the same SQL server. I've given the same user mapping and role membership for NT Authority\Network Service to both databases.
Here is what I've tried so far:
MSSQLSERVER SQL Server service is running along with SQL Server Browser, and SQL Server Agent
I've added a firewall inbound rule for SQL Server browser
Made sure TCP/IP is enabled in sql server configuration
Added port 1433 TCP to the firewall
Enabled remote connection to db server
Successfully pinged the machine
Used portqry to see the db server on UDP 1434
I can connect to the site locally when I am remotely logged into my server. Furthermore, I have an ELMAH instance in the application for error logging and that is updating the database correctly. I feel like I am taking crazy pills because this should be working and I can't find an outright error. Please help!
Here is my connection string
<add name="vfContext" connectionString="Data Source=vinformative;Initial Catalog=vf3;Integrated Security=True" providerName="System.Data.SqlClient" />

Could be EF - see here.
Also, remote access cannot work with "Integrated Security=True" as far as I know, should use "User ID=******;Password=****;Integrated Security=False".

Related

IIS can't connect to SQL Server, but an external PC can

My VB.Net code connects to SQL Server. On my PC, it succeeds. On IIS running on the same machine as SQL Server, it fails. Any ideas?
I've tested:
I've tried IP address and server name. Same result.
I've tried Integrated Security and I've tried username/password. Same result.
On the server machine, Excel and SSMS can connect to SQL server using the same server name, username and password.
The fact that my PC can connect excludes many common problems including: ip address, server name, port, firewall, turn on sql server, connection string, credentials, permissions, sql roles.
Server (IIS and SQL) info: VB.Net, connection string providerName="System.Data.SqlClient", Windows Server 2008 SP2.
My PC info: Run website in Visual Studio 2019. Connects to same DB using same connection string (not local db and not as a different user).
Code (fails on second line):
oConn = ConnectionService.DatabaseName.Connect
oConn.Open()
Connection string: connectionString="Data Source=IP Address\SQLEXPRESS;Initial Catalog=DatabaseName;Integrated Security=False;Persist Security Info=False;User ID=Username;Password=Password;" providerName="System.Data.SqlClient"
Error message: 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
Oops. Right after posting this, I found out Web.Config pointed to a different connection string. That should explain and solve everything. I had checked Web.Config, but it turns out that that wasn't the one this server was using.

Azure Web Job SQL Connection String Server not found (On Prem SQL)?

I have a web app service in Azure with web job attached. The web App is connected to my company network via VNET in Azure but the webjob wont connect to the on premise sql instance.
here is the format of connection string I am using: which works locally through visual studio.
<add name="conn" connectionString="Server=192.0.0.0\SqlInstance;Initial Catalog=Database ;user id=xxx; password=xxx" providerName="System.Data.SqlClient" />
I am only trying to select some data at the moment to prove the concept but cant get it working.
I am getting this 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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I have check the sql instance and Allow Remote connections is enabled and firewall on the server is also disabled.
is my connection string wrong?
Thanks
I have found the problem - turns out our SQL instances are not using the standard ports. once I found out the correct port using SQL Config manager and applied it to the connection string it started working.
connectionString="Server=192.0.0.0\SqlInstance,5000;
Thanks to #Jason Haley for pointing me towards Kudu which helped me find the issue.

Local IIS Web server cannot connect to SQL Server

When I use the local IIS Web server, my ASP.NET MVC application is unable to connect to SQL Server. The database is on another server. However, if I use the Visual Studio Development Server, it works just fine.
Anyone know what settings I'm missing? Should something change in my Web.config?
Yes, TCP/IP is enabled on SQL Server.
Here is the error I get -
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)
Here is my connection string -
connectionString="
SERVER=servername;
Initial Catalog=dbname;
User ID=userid;
Password=passwd"
providerName="System.Data.SqlClient"
I think you need to use IP address to connect remote database something like SERVER=59.230.212.12 in connection string. Try to connect database in management studio from where your IIS is installed . then use same setting in connection string .

Cannot establish connection to SQL Server

I am trying to access SQL DB that is located on my computer from an application that is located on a server (has IIS7).
I set the ConnectionString in the WebConfig with the IP of my computer and I always get this 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)
I wanted to enable remote connections as it was mentioned in the error. These are the things that I tried in order to make it work:
Made sure that "Allow remote connections" to this server is checked in the properties window of my server
Enabled TCP/IP in the SQL Server Configuration Manager
Right clicking on the TCP/IP and in "Properties" set the port to 1433 and removed the "0" in the Dynamic Ports
Created a new rule in the Windows Firewall to allow the connection from port 1433
Added sqlservr.exe from the MSSQL/Binn folder to "Allow a program through Windows Firewall"
Restarted the service
None of it helped. What else can I do?
EDIT:
Connection string:
<connectionStrings>
<add name="someName" connectionString="Database=someDB;Server=<my computer's IP>;User=userName;Password=123" providerName="System.Data.SqlClient"/>
</connectionStrings>
I am showing SQL Express setting this should be same in standard and other versions.
check this and follow the first link for connection specification and testing for this problem.
Check these links for checking error exists regarding this particular topic and fixing this:
Resolving “A network-related or instance-specific error"
SQLAuthority- could not open connection

SQL Server Connection String - Different Domain

I have a SQL Server connection string in a config file:
<add name="DbMaster" connectionString="Data Source=ServerName\NamedInstance;Initial Catalog=SomeDb;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
This is fine if I am running from the domain where the SQL Server is located, but I receive the following error on a different domain:
System.Data.SqlClient.SqlException: An
error has occurred while establishing
a connection to the server. When
connecting to SQL Server 2005, this
failure may be caused by the fact that
under the default settings SQL Server
does not allow remote connections.
(provider: SQL Network Interfaces,
error: 26 - Error Locating
Server/Instance Specified)
There is a trust between the domains.
I tried the following with no success:
<add name="DbMaster" connectionString="Data Source=ServerName.DOMAIN.COM\NamedInstance;Initial Catalog=SomeDb;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
I can ping ServerName.DOMAIN.COM.
I have tried connecting to the SQL Server on a different domain using SQL Server Management Studio but the same error as above is received.
Is there something obvious I am doing wrong?
If Management Studio is giving you the same error, the problem isn't with your application. The problem is with your SQL Server configuration.
Either the Trust between the Domains isn't properly configured to enable Integrated Security across domains or the SQL Server isn't properly configured to allow remote connections (like the error message states).
Integrated Security across domains is usually much more hassle than it's worth. Using SQL Server Authentication will relieve most of your headaches.

Resources