Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Target Machine Actively Refused Connection

There are several questions like this, but my situation seems a bit different. I have extremely simple code:

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

However, I get the error "No connection could be made because target machine actively refused the connection." However, I also see this problem with connections to any website. It also only appears in .NET applications, all of a sudden, none of them can access the web. Any ideas?

like image 700
Drew DeVault Avatar asked Nov 14 '22 08:11

Drew DeVault


1 Answers

For the purpose of a sanity check, I like using PowerShell to call api's, so I'd suggest that if you can.

Also, make sure to try that url in IE on the system just to make sure there's nothing weird going on (forced proxy, site is really down, DNS or hosts file is resolving it to something else, etc).

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
like image 144
James Manning Avatar answered Dec 02 '22 20:12

James Manning