"The server was not found or was not accessible" from IIS - sql-server

I have a major problem connecting to mssql server from IIS hosted application. Still same 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.
I have access to this database via Managment Studio. I also tested my connection string in a desktop testing app on the same machine and is working fine. Also, i had hosted older version of this app on another server (with an older version of IIS) and also worked fine.
I don't have direct access to database or firewall etc. Also, I cannot debug app in Visual Studio.
Any ideas?

Related

ASP.NET MVC app connects to Azure SQL Server db using server explorer, but gets "A network-related or instance-specific error" when locally hosted

I have two ASP.NET MVC applications that connect to the same Azure SQL Server database. I've used both for a long time.
I recently reinstalled my local machine and got the files for both applications from TFS. One of them works with the database just fine. The other one can connect to the database using Visual Studio's Server Explorer using the EF connection string, but when I try to run it locally I get error 26:
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 checked my local IP is allowed through the Azure firewall. Any ideas why the second application won't run locally? A port issue or a cached file?
Thanks
My app is a small test application and I only used it locally so I never implemented the Owin Identity that was included in the generated project.
I had updated Visual Studio when I updated to Windows 10. Perhaps that made the Owin Identity mandatory. When I added a connection string for the identity system the app worked without issue again.
So it was an issue with the connection string, just not the EF connection string.

Dotnet core application cannot connect to SQL server using IIS, only when using IIS Express or Kestrel

I have a .NET Core web application that fetches some data from a SQL Server. I connect to the SQL Server over the internet.
When I run the application with IIS Express or Kestrel, I can connect to the database server and retrieve data. I can also successfully connect to the database server using SQL Server Management Studio.
Here is the connection string I'm using:
"ConnectionStrings": {
"DefaultConnection": "Server=my-sql-server.someurl.com; Initial Catalog=my-sql-database; User ID=my-user-id; Password=my-password;"
}
But when I try to run the same website, on the same machine, in IIS, I get the following error message:
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: TCP Provider, error: 0 - No such host is known.)
I'm suspecting this has something to do with the dotnet core/IIS combination, and not a firewall/network/authentication issue, but I might be wrong.
The issue was simply that I was looking at the wrong connection string.
I have appsettings.json containing one connection string and appsettings.Production.json containing another.
When running the application with IIS Express or Kestrel, the first one is used, but when I publish the app and then run it under IIS, the environment is set to Production, and the production settings are used instead.
The problem was that the production connection string pointed to a database server that didn't exist anymore.
I solved this issue by adding LocalSystem to Identity in Web site Application pool.
Steps:
Select website application Pool
Right click and click Advanced Setting
Click on Identity, and change it to LocalSystem
You need to enable TCP/IP protocol on sql server. Please use following link:
Why am I getting "Cannot Connect to Server - A network-related or instance-specific error"?

Why can't I connect to the SQL Server instance on my local machine?

I have just installed SQL Server 2016 (Developer Edition) database engine on my dev machine (Windows 10).
When installing I named the instance CUBE, with Windows authentication using the current (only) user's credentials.
I can see the instance running in Services:
When I try to login using SQL Management Studio I get the following 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...
Things I've tried:
Checked the server is running (it is)
Opened firewall port 1433 (no difference)
In SQL Server Configuration Manager > SQL Server Network Configuration I've enabled Named Pipes and TCP/IP
I can't see what I'm doing wrong - can anyone help?
Make sure that the MSSQLSERVER service is running, you can check the following article from microsoft on how to manipulate the MSSQLSERVER Service.
Start, Stop, Pause, Resume, Restart the Database Engine, SQL Server Agent, or SQL Server Browser Service
finally, take a look to the following post it might help you:
Why am I getting "Cannot Connect to Server - A network-related or instance-specific error"?

Lightswitch Web Deploy - Error 26

I have a very simple Lightswitch application (HTMLClient and DesktopClient) developed on my local machine in VS 2013. I can run this locally with no issues.
I also have a remote server with IIS8 (APP02) and separate SQL server (SQL01) running SQL 2012 Standard 64 bit, both on the same domain. I can connect to the SQL server without any issues from the IIS server using a test .udl file. The IIS Server also has a sharepoint installation and all of the associated databases for this are on the SQL server.
When i Publish the Lightswitch App directly to the IIS server, after carefully following Beth Massi's article here: http://blogs.msdn.com/b/bethmassi/archive/2011/08/16/10145037.aspx?PageIndex=4#comments, I get the following error:
Error 98 An exception occurred when deploying the database for the application.
An error occurred while establishing a connection to SQL Server instance 'SQL01\SQL2012DEV'.
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)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v4.5\Publish\v2.2\Microsoft.LightSwitch.Publish.targets
1565 10
IIS8LightswitchApp
The IIS application is created successfully and i can navigate to it using the public URL, but no database is created at all. There is nothing in the Event Log of the SQL server related to this either.
When i publish the app to a package and install the .zip file in IIS manually, the app is deployed to IIS and SQL with no issues.
I've scoured this site, Lightswitch forums, and the web in general looking for a resolution but so far nothing has worked. A few things that i have tried are:
Changed the Log On user in Web Deployment Agent Service to a domain admin account
Changed the Log On user in Web Management Service to a domain admin account
Checked the firewalls on both servers (tried turning them off)
Does anyone have any suggestions I can try please? Also posted on the Lightswitch forums.
Have you tried configuring the IIS Server to host LightSwitch Apps using Web Platform Installer - http://msdn.microsoft.com/en-us/library/gg481779.aspx

SQL Server 2008 R2 connection on a VmWare Instance

Here is the scenario I am facing.
I have installed Windows 7 Professional on a VMWare.
Installed SQL Server 2008 R2.
When I launch the Server Management Studio and try to connect to the instance I get the following 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)
(Microsoft SQL Server, Error: 53)"
Now, I installed all the packages of SQL server with default settings. The only change that I had done is selected a mix-mode for authentication.
I setup a similar instance on a desktop and it works fine. Before posting it here I have searched on the web and made sure all the services, ports and protocols are enabled/running.
But I still cannot seem to connect, any help?
Ok, so finally found the solution the above mentioned problem. Not sure why, but when I give the instance name pre-appended with .\ it works fine.
.\<INSTANCENAME>
You may not have a default instance installed?
http://msdn.microsoft.com/en-us/library/ms143531.aspx

Resources