What will you do if you get the “An existing connection was forcibly closed by the remote host” error? If you have no idea to deal with it, then this post from MiniTool is what you need. You can find several useful methods in this post.
It is very convenient to manage remote computers using a sort of computer network. But sometimes, you will get an error message stating that “An existing connection was forcibly closed by the remote host” when you try to connect the remote host. Then why does this error occur and how to fix it?
Causes of an Existing Connection Was Forcibly Closed by the Remote Host in Windows
There are several causes of an existing connection was forcibly closed by the remote host, which have been listed below:
- TLS 1.1/1.0 Usage: If applications are running on TLS 1.1 or TLS 1.0, this error may be triggered because they have been depreciated. TLS 1.2 is the method when selecting the protocol used by the application.
- Cryptography Disabled: If your computer has cryptography disabled, it will prevent the use of TLS 1.2 and will fall back to TLS 1.0, which may cause the error.
- Socket Implementation: In some cases, a specific type of socket implementation can cause the error.
- Missing Code: If you are using Entity Framework, some lines of code missing will trigger this error.
- Outdate “.NET” Framework: Sometimes, this error may be triggered if the “.NET” framework has been disabled. Some tasks require the “.NET” framework to be updated to the latest version for them to work normally.
How to Fix an Existing Connection Was Forcibly Closed by the Remote Host?
After knowing some causes of the “an existing connection was forcibly closed” error, then this part will offer you some methods to fix the “connection forcibly closed by remote host” error.
Method 1: Enable Cryptography
You can enable Cryptography in Registry Editor to solve the issue. Here is a quick guide:
Step 1: Press the Win + R keys at the same time to open the Run box.
Step 2: Type regedit in the box and then click OK to open Registry Editor.
Step 3: Go to the following path:
Step 4: With the v4.0.30319 key selected in the left panel, double-click SchUseStrongCryto in the right panel and change the Value data to 1. Click OK to save changes.
Step 5: Restart your computer and then check if the problem that an existing connection was forcibly closed by the remote host is solved.
Method 2: Change Socket Implementation
An error or failure in a socket implementation may prevent some elements of the application from functioning properly, which will cause the “An existing connection was forcibly closed by the remote host” error. Thus, you can change socket implementation to solve the problem.
Step 1: Make sure you have a StateObject class with public byte buffer = new byte, public Socket socket.
Step 2: Call the Receive(Socket s) function and call the following code in void ReceiveCallback(IAsyncResult ar):
int nBytesRec = socket.EndReceive(ar, out errorCode);
if (errorCode != SocketError.Success)
nBytesRec = 0;
Step 3: After implementing this code, restart your computer to check if the error is fixed.
Method 3: Add Command Lines (Only for Entity Framework)
You may lose some certain lines of code if you are using the Entity Framework, so you can try to add command lines to solve the problem that “An existing connection was forcibly closed by the remote host”.
Step 1: Open your .edmx file and open the .context.tt file below it.
Step 2: Open the .context.cs file and add the following command lines to your constructor:
this.Configuration.ProxyCreationEnabled = false; // ADD THIS LINE !
Step 3: After you have added the command lines, reboot your computer to check if
Method 4: Update .NET Framework
If you don’t get the latest version of the .NET Framework, then you may receive the error message stating that an existing connection was forcibly closed by the remote host. Therefore, you need to update the .NET Framework to deal with the problem:
Step 1: Go to this link to download the setup.
Step 2: Run the .exe file to start the installation process, and then follow the instructions showing on the screen to finish installing the application on your computer
Step 3: Restart your computer to see whether the error is fixed.