Fixing Connection Reset Errors

If you attempt to connect to a server and it fails with a "connection reset" error, there can be several causes for this problem. It can be related to the router configuration, proxy settings, a firewall blocking the outbound connection or a conflict with your anti-virus software. It can also indicate a transitory problem with the service itself.

With the SocketTools components and libraries, this failure corresponds to error code ST_ERROR_CONNECTION_RESET (0x80042746) and the Windows Sockets error WSAECONNRESET (10054). This indicates the connection was forcibly closed by the server. You cannot recover the connection when this error occurs.

If you are certain the service your application is connecting to is functioning correctly, there's a few steps you can take on the client side to attempt to resolve the error.

Check LAN Proxy Settings

If you are using a proxy to connect to a web service and your application is configured to use the default proxy settings, disable automatic proxy detection using a control panel applet.

  1. Press Win+R and start the inetcp.cpl applet
  2. Select the Connections tab on the property sheet
  3. Click on the LAN Settings button
  4. Uncheck the Automatically detect settings option
  5. Accept the changes and restart the system

After you have restarted the system, check your application to determine if it can establish the connection. If successful, this indicates there may be a problem with the WPAD (Web Proxy Auto-Discovery) configuration.

If this automatic proxy detection is enabled, the system will attempt to search for a script which defines the proxy settings by issuing either a DHCP request or a DNS query to identify the host with the configuration script. A failure could occur if either the proxy script is invalid, or the system is unable to resolve the IP address of the host with the configuration data.

Reset Network Configuration

If the error occurs when using a direct connection, or you are not using the proxy related options in SocketTools, you can try resetting your network configuration. Third-party applications which modify your network settings or a corrupted DNS cache could cause a connection reset error.

To reset your system's network configuration, open an Administrative command prompt or use PowerShell to enter the following commands:

Restart the system after entering these commands and check if the problem persists.

These commands will reset your default configuration for your network adapter, so if you have assigned a specific IP address to the system, you will need to update this information:

  1. Press Win+R and start the ncpa.cpl applet
  2. Right-click on the network adapter and select Properties
  3. Select Internet Protocol Version 4 (TCP/IPv4) and click on Properties
  4. Check the IP address and DNS configuration
  5. Select Internet Protocol Version 6 (TCP/IPv6) and click on Properties
  6. Check the IP address and DNS configuration
  7. Accept the changes and restart the system
Disable Anti-Virus and Firewall Software

If disabling automatic proxy detection and resetting your network configuration does not resolve the issue, temporarily disable your anti-virus software and firewall. This is not a permanent solution, but it will help you determine if this is the source of the problem.

On Windows 10, you can temporarily disable Microsoft Defender and the Defender Firewall by selecting Settings > Updates & Security > Windows Security from the start menu and then click on the Open Windows Security button. From there, you can manage their settings.

For Microsoft Defender, select Virus & threat protection > Manage Settings and turn Real-time protection off. For Defender Firewall, select Firewall and network protection and then Private network to turn it off. If the system is configured to use a domain or public network instead, you can select them to disable the firewall using the same method.

As noted, this should only be used on a temporary basis as a troubleshooting method and Windows will display a warning that these services have been disabled. If disabling either your anti-virus software or the firewall resolves the issue, you may need to define exceptions for your application.

After re-enabling the firewall, you can add an exception for your application by doing the following:

  1. Press Win+R and start the firewall.cpl applet
  2. Select Allow an app or feature through Windows Defender Firewall
  3. Click the Allow another app button (bottom right)
  4. Browse to the location of your executable and add to the exception list
  5. Accept the changes and restart the system

This change will not affect any external firewalls, such as the firewall settings for your router. If adding an exception on the system does not resolve the problem, you will need to check with your network administrator to ensure the remote IP address and outbound port are not being blocked.

See Also

Blocking Operation in Progress Error
Operation Would Block Error