The remote computer refused the network connection Error

I am getting this connection error when I open the web application

This is my connection string

 <add name="DBCS" connectionString="Data Source=ABC-DEF;Initial Catalog=DB; Integrated Security=True;MultipleActiveResultSets=true" providerName="System.Data.SqlClient"/> 

Also to add, the site was working fine, this error is sudden. I have tried restarting the sql-server services and also set static tcp port. Still does not work. Where is the error?

3

6 Answers

Try one of the following

  1. make sure that server and client use the same network protocol (enable TCP/IP).
  2. Enable the service SQL Browser from your server.
  3. Enable 'Allow remote connections' setting in the server.
  4. check your server/workstation firewall so it's not blocking anything. Make sure you can access it remotely.
6

I have had same issue so wanted to share this for anyone who may come across this post in the future like I have. In my case the SQL server service would look like it is running fine but when I would try and restart the service it would hang and not be fully stopped or started and would not budge even after restarting the computer.

I resolved the issue by opening Task Manager (ctrl+shift+esc) and ending the process with the name "SQL Server Windows NT - 64 Bit". I could then restart the SQL server service and everything was fine again - no more error in the web application.

Change you connect string according to the below code, where data source=DESKTOP-6E4R4GB is your SQL server name and initial catalog=Referral2Cash is your db name.

<add name="Entities" connectionString="metadata=res://*/EDMX.Model1.csdl|res://*/EDMX.Model1.ssdl|res://*/EDMX.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DESKTOP-6E4R4GB;initial catalog=Referral2Cash;integrated security=True;MultipleActiveResultSets=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

I resolved the issue by opening Task Manager CTRL+Shift+Esc and ending the process with the name "SQL Server Windows NT - 64 Bit". I could then restart the SQL server service and everything was fine again - no more error in the web application. Then run => services.msc => start SQL Server (SQLEXPRESS)

SQL Server service

I got this same error when using SQL Express, which I resolved by noticing that I had incorrectly specified the port in the data source section of the connection string. In the connection string, I had data source=.\SQLEXPRESS,1433; when the port number should actually have been 1443. This was after enabling TCP/IP over port 1443, as detailed by this guide.

Go to sql server management studio:

  1. Left pane you see server name.
  2. Right click and select Property.
  3. Popup will show server detail.
  4. Check name property like (your_server_name\MSSQLSERVER2016) your connection string will be like
<add name="DBCS" connectionString="Data Source=ABC-DEF\MSSQLSERVER2016;Initial Catalog=DB; Integrated Security=True;MultipleActiveResultSets=true" providerName="System.Data.SqlClient"/> 

OR

<add name="DBCS" connectionString="Data Source=.\MSSQLSERVER2016;Initial Catalog=DB; Integrated Security=True;MultipleActiveResultSets=true" providerName="System.Data.SqlClient"/> 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like