A network-related or instance-specific error occurred while establishing a connection to SQL Server. http://forums.asp.net/t/1334649.aspx/1?A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Mon, 14 Jun 2010 07:54:54 -040013346492685981http://forums.asp.net/p/1334649/2685981.aspx/1?A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Hi,</p> <p>I am completely stumped.</p> <p>Im running </p> <ul> <li>&lt;div mce_keep=&quot;true&quot;&gt;Vista&lt;/div&gt; </li><li>&lt;div mce_keep=&quot;true&quot;&gt;SQL2005 SP2&lt;/div&gt; </li><li>&lt;div mce_keep=&quot;true&quot;&gt;Visual Studio 2008 SP2&lt;/div&gt;</li></ul> <p>I can connect from Management Studio using my domain credentials.&nbsp;&nbsp;</p> <p>From within the VS IDE I can connect to the database ok however when I try debugging my WebApp it comes up with</p> <p>&nbsp;<em>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)</em> </p> <p>&nbsp;The connection string from the web.config is</p> <font color="#0000ff" size="2"><font color="#0000ff" size="2">&lt;</font></font><font color="#a31515" size="2"><font color="#a31515" size="2">connectionStrings</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&gt;</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> <p>&lt;</font></font><font color="#a31515" size="2"><font color="#a31515" size="2">add</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> </font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">name</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=</font></font><font size="2">&quot;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">TESTSQLConnectionString</font></font><font size="2">&quot;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> </font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">connectionString</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=</font></font><font size="2">&quot;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">Data Source=(local);Initial Catalog=SAMPLEDB;Integrated Security=SSPI;Min Pool Size=5;Max Pool Size=60;Connect Timeout=30</font></font><font size="2">&quot;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> </font></font><font color="#ff0000" size="2"><font color="#ff0000" size="2">providerName</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">=</font></font><font size="2">&quot;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">System.Data.SqlClient</font></font><font size="2">&quot;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">/&gt;</p> <p>&lt;/</font></font><font color="#a31515" size="2"><font color="#a31515" size="2">connectionStrings</font></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&gt;</font></font></p> <p><font color="#0000ff" size="2"><font color="#0000ff" size="2">Things I have tried.</font></font></p> <ul> <li><font color="#0000ff" size="2"><font color="#0000ff" size="2">Changing ports 1433</font></font> </li><li><font color="#0000ff" size="2"><font color="#0000ff" size="2">Firewall disabling</font></font> </li><li><font color="#0000ff" size="2"><font color="#0000ff" size="2">Remote Connection enabled on SQL Server</font></font> </li><li><font color="#0000ff" size="2"><font color="#0000ff" size="2">TCP/IP and Named Pipes enabled in configuration</font></font> </li><li><font color="#0000ff" size="2"><font color="#0000ff" size="2">Modified Web.Config to use IP Addresses/ Usernames passwords /Trusted_Connections/ Different SQL Server on a different machine</font></font> </li><li><font color="#0000ff" size="2"><font color="#0000ff" size="2">Re-Installing SQL Server</font></font></li></ul> <p><font color="#0000ff" size="2"><font color="#0000ff" size="2">&nbsp;So I have absolutely no idea what to do anymore.</font></font></p> <p><font color="#0000ff" size="2">Can anyone give me suggestions on what to try?</font></p> <p><font color="#0000ff" size="2"></font>&nbsp;</p> <p><font color="#0000ff" size="2">Many Thanks</font></p> <p><font color="#0000ff" size="2">Jeremy</p> </font> 2008-10-16T04:04:30-04:002686355http://forums.asp.net/p/1334649/2686355.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Well it turns out that I have extended the membership provider but forgot to extend the role provider. So even though the membership provider was quite happy looking at my connectionstring the default Role Provider was searching for an SQLExpress install.</p> <p>Oh well hope someone learns from my mistakes :)</p> <p>Cheers&nbsp;</p> <p>&nbsp;</p> 2008-10-16T07:09:25-04:002687978http://forums.asp.net/p/1334649/2687978.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Thank you for your post...you saved me lots of time...</p> <p>I had similar problem but when trying to connect with Management Studio got the same error.&nbsp; The issue is that I had this working just a few days (weeks?) ago, so something (a patch, configuration, etc) changed.</p> <p>Anyway, before I would try to connect with &quot;machineName\InstanceName&quot; (KC118052\SQLDEV)...after reading your post and having done the rechecking&nbsp; from <a class="" title="My Digital Life" href="http://www.mydigitallife.info/2007/10/31/error-has-occurred-while-establishing-a-connection-to-sql-server-2005-which-does-not-allow-local-and-remote-connections/" target="_blank"> http://www.mydigitallife.info/2007/10/31/error-has-occurred-while-establishing-a-connection-to-sql-server-2005-which-does-not-allow-local-and-remote-connections/</a>&nbsp;I remembered some issues I was having with IIS 7.0 and changes I made.&nbsp; I tried then connecting with &quot;.\InstanceName&quot; (.\SQLDEV) and it worked!</p> <p>So the problem arose from somehow not recognizing that KC118052 was the localmachine...weird...I think I'm heading towards having to rebuild the entire machine...argh!&nbsp;</p> <p>Thank you again.</p> <p>Update:&nbsp; Found the reason(?) for the issue:&nbsp; the hosts file had the wrong public IP for my machine's name.&nbsp; Once corrected the issue went away.&nbsp; I can now connect both to .\sqldev and kc118052\sqldev</p> 2008-10-16T18:35:38-04:002711425http://forums.asp.net/p/1334649/2711425.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>&nbsp;I'm getting this same error and it's driving me nuts.&nbsp; In my project, initially I was using SQLExpress, but later changed to using an MS-Access database for simplicity's sake.&nbsp; It works just perfectly on my development machine.&nbsp; However, after uploading the files to the web server, it still seems to think I want to connect to a SQL Server database for some unknown reason.&nbsp; I've copied and recopied all of the required files to the web server, but no luck.&nbsp; What on Earth could I be missing?</p> <p>- Robert - <br> </p> 2008-10-29T03:25:21-04:002712244http://forums.asp.net/p/1334649/2712244.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Are you by any chance using linq in your solution?&nbsp; </p> <p>Is your access database installed remotely from the web server?</p> 2008-10-29T12:59:50-04:002713595http://forums.asp.net/p/1334649/2713595.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>&nbsp;No, I'm not using Linq.&nbsp; But, I'm not sure what you mean when you ask about the Access database being installed remotely from the web server.&nbsp; I simply dropped the MDB file in the App_Data folder directly under the website's root folder just like it is in my project locally.&nbsp; I'm using the AccessDataSource control manage the data connection.</p> <p>- Robert - <br> </p> 2008-10-30T03:06:09-04:002713726http://forums.asp.net/p/1334649/2713726.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Well, I sucked it up and just completely rebuilt my solution from scratch and then replaced the web forms and code files from what I had already developed and now it finally works on the server.&nbsp; Obviously there was some leftover crap somewhere (in the web.config probably) that was somehow referencing the SQLExpress database I started with.</p> <p>I'm going to try and compare the old web.config with the new, but I have a feeling this is going to remain an unexplained mystery. <br> </p> 2008-10-30T04:56:23-04:002939272http://forums.asp.net/p/1334649/2939272.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>&nbsp;</p> <p>I had similar issue, when I unistalled the SQL which had a Named Instance and Installed SQL with Default Instance. </p> <p>The Error I got is:</p> <p>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)&nbsp;</p> <p>To resolve the issue - I had to change the VSTS Options; From Tools -&gt; Options -&gt; Data base Tools -&gt; Design Time - Validation Data base -&gt; Connection Options -&gt; SQL Serevr&nbsp; Instance Name = Blank.</p> <p>Hope this info will be helpful for some people.</p> <p>&nbsp;</p> 2009-02-13T10:03:41-05:003006645http://forums.asp.net/p/1334649/3006645.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>&nbsp;I have a similar error, however, can you specify how you went about solving this issue when it occurred?<br> </p> 2009-03-14T10:36:39-04:003035549http://forums.asp.net/p/1334649/3035549.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. connectionStrings add name=&quot;ConnectionString&quot; connectionString=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Update.mdf;Integrated Security=True;User Instance=True&quot; providerName=&quot;System.Data.SqlClient&quot; connectionStrings the closing and opening braces are there. i have personally removed here. i'm also getting the same error. above is my code. please check it whether it's correct or not. on my system it's working fine. but when i upload my website to the webserver (internet) it gave this error. can u tell me it's a problem with my coding or the webserver side problem. thanks. 2009-03-25T04:42:52-04:003211316http://forums.asp.net/p/1334649/3211316.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Hi, I am using linq and my users intermittently see this issue. I am not sure what causes it. I am using Linq in my application. Do you have any resolution for this.</p> <p>&nbsp;</p> <p>Thanks,</p> 2009-06-04T18:25:09-04:003215496http://forums.asp.net/p/1334649/3215496.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Maybe this is the issue.<br> </p> <p>By default, machine.config uses the connection string LocalSQLServer&nbsp; for &quot;AspNetSqlMembershipProvider&quot;</p> <p>It's likely that your &quot;AspNetSqlMembershipProvider&quot; in the web.config does not use a connection string named &quot;LocalSQLServer&quot; <br> </p> <p>You can try to insert &lt;remove name=&quot;AspNetSqlMembershipProvider&quot; /&gt;&nbsp; right on top of &lt;add name=&quot;AspNetSqlMembershipProvider&quot; .....</p> <p>&nbsp;Hope that helps. <br> </p> <p>&nbsp;</p> 2009-06-07T01:40:04-04:003307637http://forums.asp.net/p/1334649/3307637.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Hi </p> <p>i was facing the error when opening connection using sqlconnection </p> <p>nw got solved </p> <p><br> <a href="http://sqlservererror-info.blogspot.com/2009/07/error-has-occurred-while-establishing.html">http://sqlservererror-info.blogspot.com/2009/07/error-has-occurred-while-establishing.html</a></p> <p><a href="http://aspnetmembershipprovider.blogspot.com/2009/02/error-has-occurred-while-establishing.html">http://aspnetmembershipprovider.blogspot.com/2009/02/error-has-occurred-while-establishing.html</a></p> <p><br> See This</p> 2009-07-22T05:40:36-04:003315261http://forums.asp.net/p/1334649/3315261.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>I am having the same problem you had, but I don't know how to prevent the Role Provider searching for the SQLExpress install. Where did you correct this ? I erased the SQL express connection in the web.config, but I am still getting the same error !</p> <p>Thanks in advance. </p> <p>Humberto</p> 2009-07-27T20:20:34-04:003317463http://forums.asp.net/p/1334649/3317463.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>I found a way to solve this problems. </p> <p>It is here: http://forums.asp.net/p/1450454/3317446.aspx#3317446</p> <p>Humberto<br> </p> 2009-07-28T20:48:21-04:003346680http://forums.asp.net/p/1334649/3346680.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>You little tinker!</p> <p>This issue had me stumped for hours earlier, I have deleted my connection strings in favour of switching from a live to a dev database and everything got screwed. Until I found your post about removing the machine name from my connection string and adding .\ Everything jumped back to life!</p> <p><br> </p> <p>Thank you so much.<br> </p> 2009-08-13T17:28:16-04:003351883http://forums.asp.net/p/1334649/3351883.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Hi,</p> <p>I have the same problem - i.e. I got the same error, not on a web scenario, but when trying to create a DB project with VS 2008.</p> <p>Do any of you have an ideea why I'm getting this error, as long as I'm able&nbsp;to&nbsp;connect to SQL server 2005 using the Server Explorer in VS?</p> <p>I'm not sure this thread is the right place to put this question, but the problem looks quite similar.</p> <p>Thanks,</p> <p>Mihai</p> 2009-08-17T15:16:10-04:003359935http://forums.asp.net/p/1334649/3359935.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>GO TO THE C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG DIRECTORY WHERE YOU CAN REPLACE THE VERSION OF THE FRAME WORK THAT YOU ARE USING.</p> <p>&nbsp;</p> <p>IN THIS DIRECTORY U WILL FIND A MACHINE .CONFIG FILE</p> <p>&nbsp;</p> <p>THIS IS THE SECOND AND THE MOST IMPORTANT CONFIG FILE OF YOU APPLICATION&nbsp; AND CONTAINS A CONNECTION STRING</p> <p>&nbsp;</p> <p>CHANGE THE CONNECTION STRIN SO AS IT MATCHES THE ONE IN UR WEB CONFIG FILE</p> <p>&nbsp;</p> <p>IT WORKS ABSOLUTEL FINE..,,.....</p> <p>&nbsp;</p> 2009-08-21T00:23:48-04:003368169http://forums.asp.net/p/1334649/3368169.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p><pre class="prettyprint">&lt;roleManager enabled=&quot;true&quot; defaultProvider=&quot;SqlProvider&quot; &gt; &lt;providers&gt; &lt;clear/&gt; &lt;add name=&quot;SqlProvider&quot; type=&quot;System.Web.Security.SqlRoleProvider&quot; connectionStringName=&quot;TimetrackerConnectionString&quot; applicationName=&quot;/&quot; /&gt; &lt;/providers&gt; &lt;/roleManager&gt;</pre> </p> <p>And BAM! Fixed it...</p> <p>Thanks so much for your post<br> </p> 2009-08-25T18:07:47-04:003569791http://forums.asp.net/p/1334649/3569791.aspx/1?Re+A+network+related+or+instance+specific+error+occurred+while+establishing+a+connection+to+SQL+Server+Re: A network-related or instance-specific error occurred while establishing a connection to SQL Server. <p>Why 300,000 hits.</p> <p>I think&nbsp;this thread has so many hits because people wanting to learn ASP.NET download&nbsp;VSExpress, and then have database connection issues. I downloaded VSExpress and SQL Server, and successfully completed the beginner Wrox book for VS 3.5. Then for some reason, VS Exoress stopped working. So I tried uninstalling it, and it refused to reinstall. So I tried downloading it again, and it refused to download. So I deleted anything resembling VSExpress from my machine, and I bought the complete VS2008 standard edition, which installed a version of SQL Server Compact 3.5, which in the Start &gt; All Programs appears as SQL Server 2008. And I went through the beginning book again this time with VS2008. And when I got to Chapter 11 on databases, it allowed me to place the DB that shipped with the book in the App_Data folder, but when I tried opening it, I got the error message which this thread concerns. I get a complaint about SQL Server 2005, though what's installed appears to be SQL Server 2008.&nbsp;I can imagine many people are completely green, don't know what Instance Names or IIS are really all about, and just want to write a little Web site with a database.</p> <p>So here's what I tried:</p> <p>The Wrox book recommended that if I had trouble establishing a connection to the DB, I read Chapter 18, which suggested I run the site under IIS, so I followed the instructions there. It didn't fix the problem.</p> <p>The Wrox book recommended I read Appendix B -- configuring SQL Server. It talks first about named and unnamed instances and Windows vs SQL Server authentication, and gives examples of connection strings. My web.config file has simply &lt;connectionStrings/&gt; with no content. </p> <p>So I look here and check the machine.config file in the Windows\Microsoft.NET folder and its connection string looks nothing like either. So I try setting the connect string in web-config to look like the one in machine.config, and that doesn't work. So I try deleting the one in machine.config so it looks like web.config and that doesn't work.</p> <p>So I read somewhere another magical solution and go to the Options in VS and see&nbsp;the SQL Server Instance name is&nbsp;still set to SQLExpress, so I blank it out as recommended here and try both the above connection string options and that doesn't work.</p> <p>So I see a recommendation to download SQL Server Management Studio, which I have and which I have installed, and so I'm went through the Wrox instructions for that. And that didn't work</p> <p>So now I'm reading about 16,000 other threads trying to resolve this. Maybe I'll just toss this stupid Dell in the dumpster.</p> <p>I must say, I really feel this is too much to ask of someone who just wants to learn to post a Web site with a little database like they have in the Wrox beginner book. It shouldn't be this hard. Maybe you have some IT guru at your workplace that you can ask to solve all your problems. (It infuriates me that the book keeps recommending that I contact my Network administrator... that would be me. I bought this laptop from Dell, and they didn't ship a network administrator with it.) So what the h??? I bought this thing for this purpose and I've spent a lot of money and tried really hard...</p> <p>:-) :-) :-)</p> <p>SO I'm prepared to buy your book, but at this point, I want a guarantee that after I've invested 120 hours reading and absorbing it, it WILL solve my problem, otherwise you'll fly out here personally and fix my Dell. What do you say?</p> 2009-12-16T23:05:05-05:00