How to Fix “An Existing connection was forcibly closed by the Remote Host” Error


Stuck with “SocketException: An existing connection was forcibly closed by the remote host”?

Everything was working well just a second ago, and now this annoying problem! Don’t worry you are not alone. Many people face the same issue. We have some solutions to this problem but before you pick up one for yourself let’s understand what it is exactly.

This happens when the system detects malformed data in the application and the remote side closes the connection by sending TCP/IP [RST] packet.

Also, another reason could be a network link going down between the client and server. (Socket connection)

What Causes the ‘An Existing Connection was Forcibly Closed by the Remote Host’ Error in Windows?

We have listed here some common causes for this issue. It is always a better practice to know the cause of any problem. So that you can be prepared in the future.

Cause 1: Cryptography Disabled

Cryptography secures your data from an unauthorized person and gives access to only your client. So, if cryptography is disabled for your machine system takes it as a malfunction and an issue occurs.

Cause 2:  TLS 1.1/ 1.O Usage (Transport Layer Security)

It is used for secure communication between client and server.

Update to TLS 1.2 protocol for running your application.

TLS 1.1/ 1.O were using weak encryption algorithms, those can be easily hacked.

Cause 3: Socket Implementation

The socket is an essential device at both ends in two-way communication. It is destined to a port number for sending correct data to the correct location. So, if there any bug with the application it might cause this error.

Cause 4: Missing Code in Entity Framework

An entity framework is an object-relational mapper, we use to map our data. If some code is missing this can cause an issue.

Cause 5: Outdated .NET Framework

.NET is a combined common code that comes by default with windows. Your latest application may require an updated .NET framework. This too can cause the problem.

How to Fix the An Existing Connection was Forcibly Closed by the Remote Host Error?

Now you are fairly aware of the type of problem you are facing. Let’s move towards its solutions. Implement these solutions properly so that problem gets solved.

Before diving deep just make sure your home network is working properly. Check Router, WiFi, and The Internet is accessible or not.

Solution 1: Enabling Cryptography

As cryptography is a must for encryption of your data follow the steps below the enable the cryptography.

Step 1: Search for the control panel in the status bar of your device.

Step 2: Here click on the downward arrow besideviews by

Step 3: Now, you have to choose the “small icons option

Step 4: Now click on the “Administrative tools

Step 5: Search “services” and double click on that.

Step 6: Search for “cryptographic services’ by scrolling down and right-click on it.

Here you can choose to select “start” to start the cryptography and “Stop” to stop the same.

Reboot and check if the system is working or not.

Solution 2: Enable TLS 1.2 Usage

Step 1: Click on the search option and type “run” you will see the run option. Click on it.

Step 2: Small box you are looking is the Run dialogue box. Now typeRegedit” and click on the ok button.

Step 3: Here you can see the registry editor window. Now click on “HKEY_LOCAL_MACHINE”.

Step 4: Afterwards click on the “SYSTEM

Step 5: Further click on “CurrentControlSet

Step 6: Now click on the “control.” Search and select the folder “SecurityProviders” and click on it.

Step 7: Afterwards click on the “SCHANNEL

Step 8: Now click on the “protocols.” This is an enabled protocol in your local system.

Step 9: And to enable TLS 1.2 right-click on the “protocol” option and select “new”.

Step 10: Afterwards click on the “key” option.  Once you click on the key option one new folder gets created named “New key #1” now, rename this by “TLS 1.2

Step 11: Now right-click on “TLS 1.2” and select the “new” option.

Again, click on the “key” option. Now one new folder will be created named “new key #1”.

You have to rename it by the name “client”.

Step 12: Further click on the “client” and select the “new”.

Step 13: Now, click on the “DWORD (32-bit)value” in the dropdown list.

Once you click it, it will create a new file with a “new value #1” name.

Step 14: You have to disable it by default. To disable it, typeDisableByDefault” and press “Enter”.

Step 15: Afterwards right-click on the “DisableByDefault” and select modify option.

Step 16: Just make sure that the Value data field is set to “0” and the Base is “Hexadecimal”. Now click on ok to save it.

Step 17: Further click on the “client” key and choose the “new” option.

Step 18: After that selectDWORD(32-bit)Value”.

It will create the file titled “new value #1”.

Step 19: Now rename it. Type “Enable” click “Enter”.

Step 20: Afterwards Right-click on” Enable” and select “modify”.

Step 21: Finally check these field if,

Value data field = 0

Base = Hexadecimal

Step 22: Click on “ok” and save it.

Reboot your machine and check.

Solution 3: Changing Socket Implementation

For socket implementation, you have to send the request to the server to create a socket for the new connection establishment. The socket must know the IP address and port number of the server.

You can use the overloaded implementation of EndReceive to avoid this problem.

Check for the “StateObject” class with “public byte[] buffer = new byte[1024], public Socket socket;”.

Call the “Receive(Socket s)” function and write the given code in “void ReceiveCallback(IAsyncResult ar)”.

SocketError errorCode;

int nBytesRec = socket.EndReceive(ar, out errorCode);

if (errorCode != SocketError.Success)


nBytesRec = 0;


Reboot and check to see if the problem resolve.

Solution 4: Adding Command Lines (Only for Entity Framework)

Go to your “.context.cs” file (located below “” which is you can find in “*.edmx” file). Add below code to your constructor.

public DBEntities()

: base(“name=DBEntities”)


this.Configuration.ProxyCreationEnabled = false;


Reboot and check if your system is working fine or not.

Solution 5: Updating .Net Framework

Step 1: Click on this link.

Step 2: Install it by executing the “.exe” file.

Check to see if the issue resolve.


This problem occurs in the system when there is any issue regarding a secure connection between client and server. Cryptography, sockets, and updated framework are necessary for proper communication. You should check your hardware connection too. And using the above methods, you can solve the problem easily.