An existing connection was forcibly closed by remote host in Windows 10 / 11 Fix

While trying to connect to the specified remote host from your network you may see an error message ‘An existing connection was forcibly closed by remote host’. This problem usually occurs due to an issue of socket connection between a client system and a server system. If you are looking for a solution for this issue, just follow these easy solutions to find the possible fix in no time at all.


ADVERTISEMENT

Workarounds 

1. Disable the antivirus on your computer and check again.

 

Fix 1 – Configure Java Advanced settings

Many users have reported the problem is associated with the Java SDK on their computers.

1. Type ‘Control Panel‘ in the search box.

2. After that, click on the “Control Panel” in the search result.

 

Control Panel

 

3. In the Control Panel, click on the drop-down beside ‘View by:‘.

4. Then you have to select the “Small icons” option.

 

Small Icons

 

5. Now you have to click on “Java” to open the Java Configure.

 

Java

 

6. Then, click on the “Advanced” tab.

7. After this, check the box “Enable the operating system’s restricted environment (native sandbox)“.

 

Enable The Operating System

 

8. After this, click on “Apply” and then on “OK“.

 

Apply Ok

 

Close the Control Panel window.


ADVERTISEMENT

 

Step – 2 Run SFC on Ieframe file

1. When you have changed Java settings, type “cmd” in the menu-bar.

2. After that, right-click on “Command Prompt” and click on “Run as administrator“.

 

Cmd.exe Admin

 

3. Then, type these commands and press Enter to execute them in a sequence.

prompt

sfc /scanfile=c:\windows\system32\ieframe.dll

sfc /verifyfile=c:\windows\system32\ieframe.dll
assoc

 

Prompt

 

Close the Command Prompt window.

Restart your system and check if this works or not.

 

Fix 2 – Enable Cryptographic service on your system

Enabling the cryptographic service should fix the issue.

Warning – Registry Editor is a very sensitive location on your computer. Before going ahead to the main fix, we request to make a backup of the registry on your computer.

After opening the Registry Editor, click on “File“. Then click on “Export” to make a new backup on your computer.

 

Export Registry

 

1. Type “regedit” in the search box.

2. Then, click on the “Registry Editor” to access it.

 

Regedit

 

3. Then, navigate to this registry location-

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.3031

 

4. Check if there is a key named “SchUseStrongCrypto“.

5. If there is no ‘SchUseStrongCrypto’ key, go to this area in the Registry Editor-

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319

 

6.  Then double click on the “SchUseStrongCrypto“.

 

Schusestrongcrypto

 

7. In the Edit Value window set the data as “1“.

8. Click on “OK” to save the change on your system.

 

1ok

 

Close the Registry Editor window.


ADVERTISEMENT


Restart your computer and check if the fix has worked for you.

 

Fix 3 – Force TLS 1.2 usage

In case if you have the application ready to use TLS 1.0 or TLS 1.1, instead of the TLS 1.2 version, this error message may pop up.

To fix the issue you may need to edit the source code of the particular application in the terminal.

1. Go to the root location of the application and right-click on the “global.asax” file.

2. Click on “View Code” to analyze the source code.

3. In the code, there should be an “Application_Start” section.

Just copy-paste the following lines in the section.

if (ServicePointManager.SecurityProtocol.HasFlag(SecurityProtocolType.Tls12) == false)
{
ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12;
}

 

If Add Service

 

Then save the code and run the application again. If this doesn’t work out, try changing the socket implementations on your program.

 

Fix 4 – Modify the socket implementation

Change the socket implementations should work out for you.

1. At first, check the code to make sure that there is a “StateObject” class along with “public byte[] buffer = new byte[1024], public Socket socket;“.

2. After that, you have to call one function “Recieve(Socket s)” in. Then, call this code “void ReceiveCallback(IAsyncResult ar)“.

SocketError errorCode;
int nBytesRec = socket.EndReceive(ar, out errorCode);
if (errorCode != SocketError.Success)
{
nBytesRec = 0;
}

 

Check if this has helped the situation or not.

 

Fix 5 – Add missing lines to the command line

[FOR ONLY ENTITY FRAMEWORK USERS]

In case if you are developing using Entity Framework, there is a chance you have missed a little piece of code.

1. At first, launch the “.edmx” file. After that, open the “context.tt” file.

2. Next, access the “context.cs” file and add these particular lines to your code.

public DBEntities() 
: base("name=DBEntities") 
{ 
this.Configuration.ProxyCreationEnabled = false; // ADD THIS LINE !
}

 

Now, check if this works.

 

Fix 6 – Reinstall Java SE

You can uninstall the Java SE from your computer and re-install the latest version again.

Step – 1 Uninstall Java SE 

1. Press the Windows key+R.

2. In the Run window, write and then hit Enter.

appwiz.cpl

 

Appwiz

 

This will open up the Program and Features window.

3. Check out the list of applications for the “Java SE Development Kit“.

3. Then right-click on the specified application and then click on “Uninstall“.

 

Uninstall Java Se

 

To uninstall Java from your device, click on “Yes“.

This way you have uninstalled the Java SE from your device.

Once done, close the Program and Features window.

Restart your computer.

Step – 2 Install the latest Java SE

Now, you have to install the latest version of Java on your computer.

1. Visit this Java SE downloads section.


ADVERTISEMENT

2. Just click on “JDK Download“.

 

Jdk Download

 

3. After downloading the setup, run the setup on your system.

 

Jdk Dc

 

Wait for the installation process to be over.

 

Successfully Installed

 

Check if this fix has worked for you or not.

 

Fix 7 – Flush the DNS cache

There is a chance that the connection is interfered with due to a misconfigured DNS cache.

1. Press Windows key+S. Type “cmd“.

2. Right-click on the “Command Prompt” and then click on “Run as administrator” to access the CMD terminal.

 

Cmd.exe Admin

 

3. When the terminal opens up, type this code and hit Enter.

ipconfig/ flushdns

 

Command Prompt Admin Flush Dns Command Enter

 

This will clear the DNS cache on your system. Restart the router and check if this works.

Your problem should be solved.

Alternative Tips

1. Maybe the data you are sending to the application may be distorted.

2. The client application has exhausted available resources.

ADVERTISEMENT