Wednesday, September 8, 2010

A network-related or instance-specific error occurred while establishing a connection to SQL Server. sql server 2005, asp.net, c#.net, sqlconnection

Sometimes when trying to connect to sql server 2005 database the following error message will come

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)

To resolve this error follow the steps

1. Start -> All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration. Click on Surface Area Configuration for Services and Connections. Select the instance that is having a problem > Database Engine > Remote Connections. Enable local and remote connections. Restart instance.

2. If you are not using a domain account as a service account (for example if you are using NETWORK SERVICE), you may want to switch this first before proceeding

3. If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings

4. You may need to create an exception on the firewall for the SQL Server instance and port you are using. Start > Run > Firewall.cpl. Click on exceptions tab. Add the sqlservr.exe (typically located in C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Binn), and port (default is 1433). Check your connection string as well

5. If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings

6. Check SQLBrowser; check that it is running. You may also need to create an exception in your firewall for SQLBrowser.

9 comments:

masoud said...

Hi
Thanks for reply.
My problem solved for sql express
but I use Win7 and in firewall I cann't find "exceptions tab".

Anonymous said...

Why exactly have you decided to scrape someone elses post and pass it off as your own work? I'm intreagued.

Sjimmie said...

He should have used a reference URL, but come on he is just sharing. So we can find usefull stuff, what's wrong whith that?

sql tutorial said...

thanks to share this

Truth said...

"Top Blogger" the actual author is an excellent blogger - read her blogs. copy some of the text and search - You will find her site - amazing sql skills.

DON said...

thank you very much, this certainly saved me from a big hazard!

Bhaskar said...

hi ,

great post..
i will write a post on this error with screen shots

http://csharpektroncmssql.blogspot.in/2012/04/network-related-or-instance-specific.html

Amir jamil said...

Hot Entertainment News, Bollywood Hot News, Pakistani Girls and Latest Hot Girls Pictures.
hotentertainnews.blogspot.com

Neminath Patil said...

thank you so much..