Target machine actively refuses to connect

There are several such questions, but my situation looks a little different. I have a very simple code:

WebClient client = new WebClient();
client.DownloadFile("http://www.xkcd.com", "xkcd.html");

However, I get the error message "No connection could be made because the target machine is actively rejecting the connection." However, I also see this problem when connecting to any website. It also appears only in .NET applications, and none of them can access the network. Any ideas?

+5
source share
3 answers

For health reasons, I like to use PowerShell to call api, so I would suggest if you can.

, URL- IE , , ( -, , DNS - ..).

C:\Users\james » $wc = new-object system.net.webclient
C:\Users\james » $wc.DownloadFile("http://www.xkcd.com", "xkcd.html")
C:\Users\james » dir .\xkcd.html


    Directory: Microsoft.PowerShell.Core\FileSystem::C:\Users\james


Mode           LastWriteTime       Length Name
----           -------------       ------ ----
-a---     8/26/2010  1:08 AM         7454 xkcd.html
+1

, , . , console/WinForms, ASP.NET.

0

Try accessing the site using Internet Explorer. The problem is that WebClient uses proxy settings from IE. And there are incorrect proxy settings, you will receive the message that you have.

0
source

All Articles