A network-related or instance-specific error occurred while establishing a connection to SQL Server.

Databases

Sometimes, you may get such an error when connecting to your database from SSMS or web application. "A network-related or instance-specific error occurred while establishing a connection to SQL Server."  This article will talk about how to troubleshoot such issue in Different scenes.

Note: The will likely be another sentence or two in the log error line that isn’t always unique. Each of these errors will have similar troubleshooting steps. A few examples we have seen are:

  • 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)
  • 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)
  • 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 – the remote computer refused the network connection.)
  • 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 – the wait operation timed out.)

scene 1: Your db is on our server end and your web application also run on our web server. You get above error when loading your web pages or try to login to your website.

  • step1: Verify if SQL service is running and db accessible by connect db from web connect tool:
 
    1)  If db successfully connected with this tool, that means your db is working fine on our MSSQL server. Please go to the next step.
    2)  If you could not connect to db successfully with this tool, please contact our support engineers from member account --->helpdesk panel.
                         
  •  step2:  Check your website database connection string. Make sure all info is correct and the info is the same as you used to connect db in step1. Once you verified db connection string is correct but issue persists. Then go to next step:               
Sometimes, you get above error after update db connection string for a new published app. Please note that for some asp.net applications, your database connection string may compiled into dll. So even you update connection string from web.config file, it also not work. For this case, you will need to update connection string for your app from your local Visual Studio to connect to online db(your db on our server end). Then tested to see if it works, republish your website files at last.
  • step3:  Please contact our support engineers from member account ---> helpdesk panel, let our engineers to check from web server end. 

scene 2: Your db is on our server end and you get error when connect db from local SSMS.

  • step1: Verify if SQL service is running and db accessible by connect db from web connect tool:

 
     1) If db successfully connected with this tool, that means your db is working fine on our MSSQL server. Please go to the next step.
     2) If you could not connect to db successfully with this tool, please contact our support engineers from member account --->helpdesk panel.
  • step2:  Open cmd on your local computer and run the below command, below is an example, you will need to replace sql5100.site4now.net as your db server address:
 
                           
 
If you could get a connection failed when telnet, it most probably due to your local firewall or ISP blocked the outbound port 1433, you will need to enable outbound TCP 1433 from your PC firewall and contact with your ISP to check if enable port from your firewall still not work. You can also change to another network and test. 

scene 3: Your db is on our server end, your application running on your local or another exernal web server.

  • step1: Verify if SQL service is running and db accessible by connect db from web connect tool:
 
     1) If db successfully connected with this tool, that means your db is working fine on our MSSQL server. Please go to the next step.
     2) If you could not connect to db successfully with this tool, please contact our support engineers from member account --->helpdesk panel.
 
  • step2: Run ping and telnet on the machine which run your application. Just like above scene 2, step2.
 
1) If you get below error when ping your sql server address, that means DNS resolve issue with your machine, you may need to change its local dns to google public dns by refer to: https://developers.google.com/speed/public-dns/docs/using
 
                              
 
      2) If you can ping to get sql server IP but could not telnet. You will need to enable outbound TCP 1433 from your machine firewall and contact your ISP to check if enable port from your firewall still not work.
 
                              
 
        3) If you can telnet our SQL server from your machine but still could not connect, you will need to check your website database connection string to see if it is correct.
 
scene 4: Your website application is running on our web server, you are trying to connect it to your local db or db running on external db server.
Note: We would suggest customers to backup and restore db to our end. The performance will be better than connect to a remote db due to our web and db servers within LAN. 
For this case, you will need to confirm your remote db allow connection from our web server. At the same time, you can contact our engineers to telnet your db server from our web server end to see if any connection issue.