Introduction
One day, I was attempting to connect with MS SQL Server but it didn't succeeded not even after making attempt once more and once more. I ran into error provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server on server. I'm providing you all necessary steps to resolve issue error: 40 - Could not open a connection to SQL Server. To succeed this issue, I would recommend to experience gave all strides one by one until your issue get resolve. This error comes out in many ways so that you need to check out all steps provided in this article until you succeed your issue.
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)
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016”
Step 1: First Step check your SQL services are running fine.
Step 2: Click on “Start Window” and expand “Microsoft SQL Server 2008 R2” and click on “SQL Server Configuration Manager”.
Step 3: Now click on left pane “SQL Server Services” and check for “SQL Server (SQLEXPRESS)” running or not, if it is experiencing in green colour then it’s working fine.
Step 4: Now check for “SQL Server (MSSQLSERVER)”, if it's experienceing be in green color means running fine.
Step 5: Now check for “SQL Server Browser” running or not, you've to make sure it's green marked.
Step 6: Now click on “Aliases“ left pane, make assure on right pane that there should be empty aliases, if requires then should recreate from fresh.
Step 7: Now check for SQL Server Default Portal 1433, if you have not already added then follow to open “Ctrl + R”, type “Firewall.cpl” then Firewall will open and Click on “Advanced Settings”.
Step 8: Click on “Inbound Rules” in left pane and click on right pane “New Rule”.
Step 9: Then Click on “Protocol and Ports” and click on “Specific local ports” and write SQL default Port No “1433”.
Step 10: Now write name on SQL Port Name and click on “Finish” button.
Step 11: Now click on “Client Protocols” in left pane, next click on right pane “TCP/IP” and click on “Property” then you check that your default Port “1433” has been populated.
Step 12: Now Open “SQL Server Management Studio” and right click, now property window open and click on “Property”.
Step 13: Now click on “Connections” option and Check option “Allow remote connections to this server” and click now on “OK”.
Step 14: You have to Ping for your IP Host Address on your command prompt "cmd" console.
Step 15: Check for Firewall blocking SQL Server Port 1433
Step 16: If you have already access to development machine, production server then it'll be helpful greatly. Press (Windows + R) to open Run window to launch program quickly. Now type “EVENTVWR” and a new window'll be open, now expand left pane, you'll be able to check here “Windows Log” to look into issue very closely and specifically.
Step 17: We can use also Netstat Command to display how communicating with other computers or networks.
netstat [-a] [-b] [-e] [-f] [-n] [-o] [-p protocol] [-r] [-s] [-t] [-x] [-y] [time_interval] [/?]
Detail Error Description:
“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)
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1016”
Step 1: First Step check your SQL services are running fine.
Step 2: Click on “Start Window” and expand “Microsoft SQL Server 2008 R2” and click on “SQL Server Configuration Manager”.
Step 3: Now click on left pane “SQL Server Services” and check for “SQL Server (SQLEXPRESS)” running or not, if it is experiencing in green colour then it’s working fine.
Step 4: Now check for “SQL Server (MSSQLSERVER)”, if it's experienceing be in green color means running fine.
Step 5: Now check for “SQL Server Browser” running or not, you've to make sure it's green marked.
Step 6: Now click on “Aliases“ left pane, make assure on right pane that there should be empty aliases, if requires then should recreate from fresh.
Step 7: Now check for SQL Server Default Portal 1433, if you have not already added then follow to open “Ctrl + R”, type “Firewall.cpl” then Firewall will open and Click on “Advanced Settings”.
Step 8: Click on “Inbound Rules” in left pane and click on right pane “New Rule”.
Step 9: Then Click on “Protocol and Ports” and click on “Specific local ports” and write SQL default Port No “1433”.
Step 10: Now write name on SQL Port Name and click on “Finish” button.
Step 11: Now click on “Client Protocols” in left pane, next click on right pane “TCP/IP” and click on “Property” then you check that your default Port “1433” has been populated.
Step 12: Now Open “SQL Server Management Studio” and right click, now property window open and click on “Property”.
Step 13: Now click on “Connections” option and Check option “Allow remote connections to this server” and click now on “OK”.
Step 14: You have to Ping for your IP Host Address on your command prompt "cmd" console.
Step 15: Check for Firewall blocking SQL Server Port 1433
Step 16: If you have already access to development machine, production server then it'll be helpful greatly. Press (Windows + R) to open Run window to launch program quickly. Now type “EVENTVWR” and a new window'll be open, now expand left pane, you'll be able to check here “Windows Log” to look into issue very closely and specifically.
Step 17: We can use also Netstat Command to display how communicating with other computers or networks.
netstat [-a] [-b] [-e] [-f] [-n] [-o] [-p protocol] [-r] [-s] [-t] [-x] [-y] [time_interval] [/?]
Authentication And Host Name Setting (SQL Server Error 25 And 27)
I am getting few queries routinely regarding authentication and host name resulting issue into SQL error No 25 & 27 to resolve these issues attempt below points and I posted this error SQL Server Error 25 And 87 with more detail in my earlier article.- Verify your Authentication whether it's Windows or SQL Server.
- If using local SQL database then you'll able to use . (dot) only instead of server name.
- Enter your correct host name (hostname\SQLEXPRESS), myhostname\SQLEXPRESS (in case of SQL Server Express) or (myhostname\mssqlserver).
- You'll also attempt alternatively (localhost\SQLEXPRESS) or (localhost\mssqlserver).
Conclusion
I have attempted my best to incorporate all fixing to dispose of this quite common issue of error: 40 – Could not open a connection to SQL. You'll keep posting me up message, if you still continue to face any further issue.Suggested Links:
- Login failed for user iis apppool default apppool
- The underlying provider failed on open
- Saving Changes not permitted in SQL Server
- MVC ASP.Net Interview Questions And Answers
Thank you so much for posting this article Anjan. Helps me lot.
ReplyDeleteHello Sir................,
ReplyDeleteAbove Problem occure in my pc also
(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: SQ L Network Interfaces, error: 26 - Error Locating Server/Instance Specified),,,,,,,,,,,,,,,,,,
But In My PC I have use "MICROSOFT SQ L SERVER 2012 "...........then can u tell m this is all steps are common or different
Priya, It sounds like are you missing/incorrect your data source name, you can check link http://msdn.microsoft.com/en-us/library/ms191464.aspx , it will work perfectly for SQL Server 2012, pls check all steps mentioned above correctly.
DeleteOn 'sql server services' SQL Server (MSSQLSERVER)” is missing. I tryed ti uninstall-reinstall SQL SERVER but the problem still continous.
ReplyDeleteAny suggestions ?
Can you please share your exact problem right now facing, did you check all steps mentioned above.
Delete11 steps are ok , 12 step how to possible without open sql server
DeleteYou can ask for your SQL database provide to confirm “Allow remote connections to this server” if database is on remote machine.
DeleteSQL Server (MSSQLSERVER) is missing...
ReplyDeletePlease suggest me what i do next
check for Start the service for (MSSQLSERVER), press Ctrl+R then locate SQL Server (MSSQLSERVER) service, then mouse right click, go "Properties", click tab "Log On" try with "This account". check for all SQL server services to green.
ReplyDeleteThanks to you bro. Keep Posting for another tutorials. It works at me.
ReplyDeleteSure tbabbit, I'll keep posting for another good tutorials on ASP.Net (C#), SQL Server issues. Thanks for motivation.
Deletehello sir, i hve same problem & i have tried ur suggested steps but it is giving same error. please suggest me what to do?
ReplyDeleteI'm back from New Year, did you tried all steps. I thinks you should get your resolutions right in the mentioned steps.
DeleteThis comment has been removed by a blog administrator.
ReplyDeleteHello Anjan
ReplyDeletei followed all the steps but two steps i do not know how can i do it
the first step is Sql server browses is shown in red not in green so how can i fix it
the last step when i write in console prompt
ping technologycrowds.com
i got this :
Pinging technologycrowds.com [216.239.34.21] with 32 bytes of data :
request timeout
request timeout
request timeout
request timeout
Ping statistics for 216.239.34.21 :
Packets : Sent=4, Received=0, Lost=4 <100% loss>
Check Step #2, #3, #4, #5 carefully, you have to ping your website not www.technologycrowds.com so it also carefully, when you ping your website it will reply if sending request timeout then there is issue in your website.
Delete@Anjan Kant
ReplyDeleteI got this error to
But when i tried above steps
i didn get sqlserver (mssqlserver) services wht to do?
Please follow carefully Step 1, Step 2, Step 3, Step 4, Step 5, Step 6 to resolve your issues after that you still find the same issue (sqlserver (mssqlserver) services) let me know.
ReplyDeleteThank you sir it working properly This artical help to me and other also ....Thank you so much...
ReplyDeleteThanks.Now i am able to connect to remote database and it is working completely fine
ReplyDeleteTITLE: Connect to Server
ReplyDelete------------------------------
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: 28 - Server doesn't support requested protocol) (Microsoft SQL Server, Error: -1)
" Verify that the instance name is correct and that SQL Server is configured to allow remote connections" did you checked this one and again verify all steps given above, if you still persists the issue let me know.
DeleteI followed through yoga highlight your guidelines, and having problem with step 4 & 5.
ReplyDelete+ On step 4, I do not have SQL Server( MSSQLServer ) on my SQL Server Configuration Manager.
+ On step 5, I right click to start SQL Server Browser, and it failed. This is the message that I got
" the request failed or the service did not respond in a timely fashion. Consult the event or other applicable error logs for details"
Please please help me with this issues.
Thank you
Providing you few links to resolve Step 5 issue 1) http://blog.sqlauthority.com/2011/03/29/sql-server-fix-error-the-request-failed-or-the-service-did-not-respond-in-timely-fashion-consult-the-event-log-or-other-applicable-error-logs-for-details/ 2) http://stackoverflow.com/questions/1617402/the-request-failed-or-the-service-did-not-respond-in-a-timely-fashion 3) https://biatlink.wordpress.com/2013/04/29/sql-server-request-failed-or-the-service-did-not-respond-in-a-timely-fashion/ if you still facing the issue then let me know.
Deleteprovider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
ReplyDeleteGo to Sql server configuration manager in sql native client configuration, enable client protocols
DeleteAlready provided steps 16 to resolve the issue "provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)" if you are still missing then can check this link also http://blogs.msdn.com/b/sql_protocols/archive/2007/03/31/named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server.aspx
ReplyDeleteHi, Thank you so much for this great width thank the hope that it will be successful
ReplyDeletehow can i perform the task of connecting a database(mdf) file in remote machine and accessing it my machine using windows form(C#).i am not able to establish a centralized database in my laptop.plz help
ReplyDeleteYou can access remote database in two ways as following:
Delete1) You can develop webs service and host it online to access across the network.
2) You can assign a public IP address and access it remotely.
thanks for this solution !!!!!!!!
ReplyDeleteHi Anjan,
ReplyDeleteI couldn't connect to the SQL SERVER 2005 database engine to itself, but It can be connected to the other PC's in the LAN. Please do the needful.
Narendran N
n4narendran.theblogspot.in
Can you check your firewall (PC Security) which is stopping to connect your own PC, can you specify your error message while not connecting.
DeleteHi Anjan kant, Thanks for detailed explanation. But facing a error like that only.
ReplyDeleteFollow the all steps as mentioned.
Please through some light on this issue. Its very urgent.
Thanks in advance,
Bhaskar N
Bhaskar, Can you specify your error exactly here, so that I can tell you exactly.
DeleteTITLE: Connect to Server
ReplyDelete------------------------------
Cannot connect to ASWAK\SQLEXPRESS.
------------------------------
ADDITIONAL INFORMATION:
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) (Microsoft SQL Server, Error: -1)
Did you check all 17 steps, if you confirm all steps, it is very sure, your SQL server will connect. If any more required let me know.
DeleteTITLE: Connect to Server
ReplyDelete------------------------------
Cannot connect to NG.
------------------------------
ADDITIONAL INFORMATION:
Login failed for user 'ng\negar komputer'. (Microsoft SQL Server, Error: 18456)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476
------------------------------
BUTTONS:
OK
------------------------------
this is my error
Microsoft SQL Server, Error: 18456 this error due to invalid User Name/Password, please confirm your SQL Server for valid login detail.
Deletehow can i download microsoft sql server 2008,please send me the link.32 bit os
ReplyDeleteHere is a link http://download.cnet.com/Microsoft-SQL-Server-2008-Express-32-bit/3000-10254_4-75451532.html to download SQL Server 2008 (32 bit OS).
DeleteThank you. Now connected
ReplyDeleteWelcome, keep more reading on SQL Server error.
DeleteHi Anjan Kant, Thanks for the Post Its resolved my Problem !
ReplyDeleteYou have described the solution briefly in your post Great!
thnx sir
ReplyDeleteSir,
ReplyDeleteWhen I open "Microsoft SQL Server Management studio"
I get only two folder which is "Running Packages" and "Stored Packages" What should I do to sort out this problem?
Here is a video link which demonstrates how to open Microsoft SQL Server Management studio
Delete
ReplyDeleteSir, Please solve this problem
Cannot connect to \SQLEXPRESS.
------------------------------
ADDITIONAL INFORMATION:
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: 25 - Connection string is not valid) (Microsoft SQL Server, Error: 87)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=87&LinkId=20476
Check below points
Delete1) Verify your Authentication whether Windows or SQL Server.
2) if using local sql database then you can use . (dot) instead of server name, try other one also
3) enter correct host name: (hostname\SQLEXPRESS) myhostname\SQLEXPRESS (in case of SQL Server Express) or (myhostname\mssqlserver)
4) try this one also (localhost\SQLEXPRESS) or (localhost\mssqlserver)
hello sir to do step 12 i need to login but I am getting same message saying named pipes provider error:40.... i cross checked above steps before step 11 i did all right. can you please help me.
ReplyDeletecan you confirm me are you using your local db or remotely, also comply steps after/on steps 12 definitely it will help you.
DeleteHello Sir, there are no items in the main(right panel) when i click SQL server services as said in step 5. What might be the mistake.. Please help as soon as possible.
ReplyDeleteFirst check that your SQL server services running or not through control panel or type immediate run window "services.msc" and check SQL Server services running or not.
DeleteHello Sir, in Step 5,when i click on SQL server services no items are present to be shown. Please help me as soon as possible
ReplyDeleteconfirm first above reply.
Deleteerror 40: so cannot find sqlexpress server so what I do...
ReplyDeleteI not intall any sql server..
I used only providing by visual basic2010 installing time given sqlexpress server...
how to solve my error gime me in step wise...
pls
First of all, confirm your machine running SQL server running or not because this error is totally concerned with SQL Server, moreover check steps for 7 , 8, 9, 10, 15, 16, 17 carefully.
DeleteHi,
ReplyDeleteI have created a simple asp.net web application and I am trying to read data from the DB but I am getting the same error as the title of this article.
My Server Name is localhost\SQLEXPRESS but I am using
SqlConnection con = new SqlConnection("data source=.;database=master;integrated security=SSPI");
this as my con object command.
I have tried all the steps above, Can you please help and suggest as to why I am still getting this error.
Are you able to connect SQL Server Management Studio directly as you provided login credentials here.
DeleteHi Anjan
ReplyDeleteI am facing the same issue on my live (not on my PC)site, my site works fine mostly, suddenly i starts showing me following error without any updations in any files:
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: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
after some time it starts working automatically, what all i do is just wait for some time.
could you please help me??
Thanks in advance
If are you using .mdf SQL server database file then you need to install SQL Server Express on that particular machine. So you can't use .mdf file without installation, if you are looking for embedded database then prefer SQLite, SQL Server CE (Compact Edition), RavenDB etc, these work without installation.
Deletemy mdf is missing from app data folder . and sm error ocuured what should i do pls help me
ReplyDeleteif mdf file is missing then you should add mdf file in your app data folder.
Delete