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 0x80042746 and Windows Sockets error 10054. This indicates the connection was aborted by the server and 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.
- Press Win+R and start the inetcp.cpl applet
- Select the Connections tab on the property sheet
- Click on the LAN Settings button
- Uncheck the Automatically detect settings option
- 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.
Check the Network Configuration
If the error occurs when using a direct connection, or you are not using the proxy related options in SocketTools, flush your DNS cache and, if you're using a dynamic IP address, renew your IPv4 and IPv6 addresses.
Open an Administrative command prompt or use PowerShell to enter the following commands:
ipconfig /flushdns
ipconfig /release
ipconfig /renew
ipconfig /release6
ipconfig /renew6
Also check to make sure your network interfaces are configured correctly:
- Press Win+R and start the ncpa.cpl applet
- Right-click on the network adapter and select Properties
- Select Internet Protocol Version 4 (TCP/IPv4) and click on Properties
- Check the IP address and DNS configuration
- Select Internet Protocol Version 6 (TCP/IPv6) and click on Properties
- Check the IP address and DNS configuration
- Accept any changes and restart the system if necessary
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:
- Press Win+R and start the firewall.cpl applet
- Select Allow an app or feature through Windows Defender Firewall
- Click the Allow another app button (bottom right)
- Browse to the location of your executable and add to the exception list
- 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
Resetting the Windows TCP/IP Stack
Operation Would Block Error
Blocking Operation in Progress Error