This particular error occurs when your LAN settings may have been changed and incorrectly set. Malware may also change these settings automatically. When you receive this error, the ping may work as usual, but you would not be able to access any website in any browser.
The remote device or resource won’t accept the connection
The first thing you need to do is to scan your computer with your antivirus software. Having done that, you may check your LAN settings and see if you need to change them. To change LAN settings, open type inetcpl.cpl in Start Search and hit Enter to open Internet Options. After opening the window, switch to the Connections tab and click on the LAN settings button. Now, if the Use a proxy server for your LAN option is checked, uncheck it and save your changes.
This is expected to help. If it does not help, also uncheck the Automatically detect settings check box, click Apply, and see.
Let us know if this helped.