What exactly is an instance-specific error - asp.net

Okay so I got:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server.
Now I know what the problem is (web server couldn't see the database server), however I'm wondering what exactly an instance specific error is and if people have examples? I know it's specific to an instance but what kind of things would fall under that?

Instance in this context means an instance of SQL Server. As you remember, SQL server can be installed in multiple instances on the same machine. Instances are adressed machinename\instancename or by IP x.y.z.t:instanceport.
The error means that the instance you are trying to connect cannot be reached while this is unknown whether or not other instances are running and can be contacted. Thus the
"instance specific" error.

How to Troubleshoot Connecting to the SQL Server Database Engine is a good article about troubleshooting the exception you reference in your question. It summarizes the causes to the following:
This error usually means that the SQL Server computer can't be found
or that the TCP port number is either not known, or is not the correct
port number, or is blocked by a firewall.
If you go through the troubleshooting steps, you will find out that the place to search for the problem is not only network related, but it could be, for example:
the database engine not being configured to accept remote connections on the specific instance
the used protocol not being enabled (for example TCP/IP) on the specific instance
I guess that the exception message tries to keep your troubleshooting focus on more than one option when it comes to put the the finger on the certain culprit subsystem. Or maybe it's just a way of reporting a connection related exception which is impossible to trace.

Related

MSDTC and COM+ with Oracle database on Unix based server error out

I am getting following error when COM+ object with required transaction try to communicate with Oracle database.
"Following is the error text….
Communication with the underlying transaction manager has failed.
Inner Exception:
The MSDTC transaction manager was unable to pull the transaction from the source transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn't have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers. (Exception from HRESULT: 0x8004D02B)
"
<Transaction(TransactionOption.Required)>
The same code works on some machine and not others.
Have tried firewall (as per google search result). There is no firewall
Have tried removing and adding COM+ components.
Tried registry cleaner ...
Any inputs is most welcome.
Thanks
I would confirm network DTC access is enabled:
Found the root cause of the issue.
It was to do with the fact that an external database access (to sql server) was being made in the call stack and the SQL Server was blocking MDTC port number. Its now fixed.
EDIT:
When I said it was fixed, as it turned out it wasnt.
In fact the problem was to do with the connection was being enlisted in MSDTC by default. To disable this just add enlist=false; in the connectionstring and it will stop automatically enlist the connection to the MSDTC.

Tracking down database connection issues

Background
We have a number of web applications on different web servers that connect to a single database server. Over the past couple months, we have noticed that every once in awhile, our web servers won't be able to connect to the database server.
Our Environment
We have a couple different web environments, some running ColdFusion and others running .NET. The .NET apps are both Web Forms and MVC. They span multiple versions from 2.0 to 4.5. Both the ColdFusion and .NET web servers are windows based machines. Both the ColdFusion and .NET web environments are clustered and some of the machines are physical while others are virtual.
Our database server is SQL Server 2008 r2. It houses multiple databases. Each application has its own database user that it connects with to the server that only gives it access to a particular database.
Other Facts
When we notice issues, they occur in short bursts that last anywhere from a couple seconds to a couple minutes.
When we notice issues, the burst contains errors from multiple different appliations, not just one app at at time.
When we notice issues, the burst contains errors from applications from different web environments. (This makes us think we can rule out that the apps themselves are the issue)
The burst of connection issues happen at various times throughout the day and night. They are not always during times of high usage.
We have monitored things like number of user connections, memory, IO, CPU usage, etc... and we have not seen spikes or anything else that might point to a problem.
We have installed wireshark on the web and db servers in hopes of catching the problem without any success.
Questions
Does anyone have suggestions on where I should look next?
Are there properties of the database that could cause this?
Is there any way to "monitor" the connection between the database and web server in a better manner?
Is there anything that can be done on the app side to better understand what is happening?
Errors Caught by Apps
.NET errors
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)
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
ColdFusion errors
Error Executing Database Query. The TCP/IP connection to the host has failed. java.net.ConnectException: Connection timed out: connect The error occurred on line 38.
Error Executing Database Query. Connection reset by peer: socket write error The error occurred on line 91.
Error Executing Database Query. Timed out trying to establish connection The error occurred on line 38.
In CF, I once had an issue like what you were seeing. I had CF on 1 server, and sql 2008 r2 on another server. I would see CF errors like you posted below. To help trace it to a network error I wrote something like this:
1) created a down.bat
tracert serverip
2) I then put a <cftry><cfcatch> around the query.
When the query generated the error I would execute
<cfexecute name="C:\path\to\down.bat" variable="log" timeout="60" />
<cfmail to="ME" from="Server" subject="SQL DOWN">
Server Debugging Info:
------------------------------------------------------------
#now()#
#cfcatch.Detail#
#cfcatch.Message#
#log#
</cfmail>
</cfexecute>
This helped me fix my situation which ended up being hardware at the datacenter.

SQL Server was not found or was not accessible

What is the problem below?
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)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
How can this be solved?
All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> SQL Server Services, and check if SQL Server service status is “Running”.
Seeing as this result is second in Google when searching for:
Server is not found or not accessible
I'll add to this post. Colleague of mine has search for an entire day on this problem, checking his connection string and double checking his code. He could connect to the server using SQL but his application wouldn't connect.
Turns out he was running his application from a network share. Network shares only have partial trust and will produce this misleading exception as a result.
Move the project to your local drive and try again. Hope this helps someone!
We were getting this intermittently on our .NET website which accesses an SQL Server database on another server. I tried several things, including making sure I was closing all SQLConnections and recycling applications pools more frequently. These helped some but the problem still occurred from time to time. What it turned out to be was a DNS issue.
I resolved it by changing the connection string Data Source value from a domain name to an IP address, e.g from:
Data Source=My-SQL-Server;Initial Catalog=database-name;Integrated Security=true
to
Data Source=10.1.2.237;Initial Catalog=database-name;Integrated Security=true
This means pretty much exactly what it says. For some reason the computer the code was running on could not communicate with the SQL Server. This could be caused by a lot of things: Firewall issues, DNS/Name resolution, SQL Configuration (not configured to accept TCP/IP connection). Just to name a few.
You need to restart the MS SQL service. Please follow these steps:
1- Press window sign + R to open Run Window.
2- Type services.msc and press Enter.
3- Look for SQLSERVER(MSSQLSERVER) in the services list.
4- Right click on that service and choose REFRESH or START.
Hopefully it works.
Just go through following steps:
All Programs
Microsoft SQL Server 2008 R2
Configuration Tool
SQL Server Configuration Manager
A pop up will open click on yes.
Select Sql Server Services (At left side) and Make sure status is running for all services (At right Side)
One thing you can try is to open server explorer in Visual Studio.
Click Connect to database.
The datasource will be Microsoft SQL Server Database file. Click ok
Type in the Database file name or click Browse...
Click Test Connection and make sure it works.
If it does...click on the Advanced.. button.
Copy the Data Source text at the botton of the screen.
Almost everytime I see this error I was trying to use an instance name something like "long_pc_name/MSSQLExpress" (this is what shows up in MSSMS)
And every time it just needs to be "(LocalDB)\MSSQLLocalDB".
If your connection string is pointing to a local db...
connectionString="Data Source=(localdb)\
Server=localhost\SQLEXPRESS;Database=
Another cause of this error is: you might not have Sql Server installed in your system.
Download Sql Server Express here:
https://www.microsoft.com/en-us/download/details.aspx?id=55994
Install it and try again.
You can use this connection string to connect to it:
Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;
Your local server name is localhost\SQLEXPRESS.
Replace database with your database name.
Refer to this post if you still have trouble connecting:
Why am I getting "Cannot Connect to Server - A network-related or instance-specific error"?
I was trying to run the MVC Movie tutorial but I had the error in question. So I created a new MVC project and copied its connection string and used that to replace the one in the tutorial. Basically, replace this:
Data Source=(LocalDB)\v11.0
With this:
Data Source=(LocalDb)\MSSQLLocalDB
For all connectionString properties.
Go to SSMS and check if the SQL server is accessible there.
Try to replace domain name by IP address. Check if you have sufficient authorization,and other requirements fulfilled.
Try to check LAN connection and VPN connection, if required.

Sporadic SQL Server error when trying to connect to the database

I will get the error below randomly when I'm running an asp.net application I am working on. Usually it will happen ever 3 days or so and I am forced to restart my machine to fix it but it's been getting worse and now a reboot dosn't seem to fix anything. I'm running the application on my machine and doing a lot of debugging. All interactions with the db are done through linq to sql. The db is on another server that I am connecting to. Has anyone run into this before? Any suggestions?
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.)
It may be DNS, try to use some different DNS addresses. :)
I've seen similar before but it was related to a faulty network card that was dropping packets. Have you had any other strange network problems?
In your connection string to the db is the host entered as a hostname or an IP address. If by name try swapping to its IP address instead. This won't solve the underlying problem by may workaround it for you.
Edit
Also have a look at this SO answer here. Are you leaving connections open/orphaning them? That would ring true with the disconnect happening at regular time intervals..

Why is this error happening a lot "asp.net, sql server"?

I have this error which happen many times on my site:
"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 - An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.)"
My site files are on a server and the database on another server, but on the same network.
Anyone know what may cause this problem and how to solve?
Notes:
- When i restart the website server the problem solve and everything work fine.
- Sure my sql server allow remote connections from this website server
It's a pretty generic error when the application can't get to the database. Perhaps you are leaving connections open after using them? There could be a limit on the amount of concurrent connections by user or server.
It's a networking error of some kind, or you're specifying the instance name incorrectly. I've recently seen both cases. In one case, I had moved a connection string from one system, to another system that had a different instance name installed. In another case, I had a server running in a Virtual Machine - about ten minutes after the machine was resumed from suspension, the machine would lose its DHCP lease (and therefore its connectivity).
It could be just about anything, and you'll have to go find out, perhaps by using a network monitor program like Microsoft Network Monitor 3.2.
I found a good article talking about this error, i think it shows the real reason
Understanding the error “An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.”

Resources