简体   繁体   English

目标机器主动拒绝连接

[英]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. 它也只出现在.NET应用程序中,突然之间,它们都无法访问Web。 Any ideas? 有任何想法吗?

For the purpose of a sanity check, I like using PowerShell to call api's, so I'd suggest that if you can. 出于理智检查的目的,我喜欢使用PowerShell来调用api,所以如果可以,我建议你。

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). 此外,请确保在系统中的IE中尝试使用该URL以确保没有任何奇怪的事情发生(强制代理,网站真的关闭,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

The user that your code is running as is relevant. 代码运行的用户是相关的。 For example the code might work in a console/WinForms app but not in an ASP.NET app. 例如,代码可能在控制台/ WinForms应用程序中工作,但在ASP.NET应用程序中不起作用。

Try to go to the site using Internet Explorer browser. 尝试使用Internet Explorer浏览器访问该站点。 The problem is the WebClient uses proxy settings from IE. 问题是WebClient使用IE的代理设置。 And there are any wrong proxy settings you'll get the message you've got. 并且有任何错误的代理设置,您将获得您已收到的消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SignalR错误“由于目标机器主动拒绝连接,因此无法建立连接” - SignalR Error “No connection could be made because the target machine actively refused it” 无法建立连接,因为目标计算机主动拒绝了它216.58.212.106:443 - No connection could be made because the target machine actively refused it 216.58.212.106:443 '由于目标机器主动拒绝它,因此无法建立连接 - 'No connection could be made because the target machine actively refused it 由于目标计算机主动拒绝连接,因此无法建立连接-客户端 - No connection could be made because the target machine actively refused it - client side 无法建立连接,因为目标计算机主动拒绝了127.0.0.1:8000 - No connection could be made because the target machine actively refused it 127.0.0.1:8000 由于目标计算机主动拒绝连接,因此无法建立连接-套接字程序 - No connection could be made because the target machine actively refused it - Socket Program 没有连接,因为目标机器主动拒绝它为什么? - No connection could be made because the target machine actively refused it why? “无法建立连接,因为目标机器主动拒绝它” Nethereum 异常 - “No connection could be made because the target machine actively refused it” Nethereum exception “无法建立连接,因为目标计算机主动拒绝了它” - “No connection could be made because the target machine actively refused it” 无法建立连接,因为目标计算机主动拒绝它127.0.0.1:32450 - No connection could be made because the target machine actively refused it 127.0.0.1:32450
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM