C# '无法建立连接,因为目标机器主动拒绝它
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15247186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'No connection could be made because the target machine actively refused it
提问by user2094406
I am running a client application which should connect to a server side application in .NET.
我正在运行一个客户端应用程序,它应该连接到 .NET 中的服务器端应用程序。
Are there any restrictions on the number of connections a listening port can receive on the server? I'm asking because I got an exception Message:
服务器上侦听端口可以接收的连接数是否有任何限制?我问是因为我收到一条异常消息:
No connection could be made because the target machine actively refused it 1.9.64.212:62131
无法建立连接,因为目标机器主动拒绝它 1.9.64.212:62131
回答by fithu
This must be a firewall issue (or another connectivity issue), or the server was not started correctly.
这一定是防火墙问题(或其他连接问题),或者服务器未正确启动。
回答by Slava
The error "No connection could be made because the target machine actively refused it" means that your request got through so it is not a firewall issue. This message means that noone listens to this port. Make sure your server application is running and that it listens to the right port number (and IP address). On your server computer you can run "netstat -a -b" to find port numbers and server applications that listen to those ports.
错误“无法建立连接,因为目标机器主动拒绝它”意味着您的请求已通过,因此它不是防火墙问题。此消息意味着没有人侦听此端口。确保您的服务器应用程序正在运行并且它侦听正确的端口号(和 IP 地址)。在您的服务器计算机上,您可以运行“netstat -a -b”来查找端口号和侦听这些端口的服务器应用程序。
回答by Slava
There are some possible reasons for that:
有一些可能的原因:
- The server is not running. Hence it wont listen to that port. If it's a service you may want to restart the service.
- The server is running but that port is blocked by Windows Firewall or other firewall. You can enable the program to go through firewall in the Inbound list.
- There is a security program on your PC, i.e a Internet Security or Antivirus that blocks several ports on your PC.
- 服务器没有运行。因此它不会监听那个端口。如果它是一项服务,您可能需要重新启动该服务。
- 服务器正在运行,但该端口被 Windows 防火墙或其他防火墙阻止。您可以在入站列表中启用程序通过防火墙。
- 您的 PC 上有一个安全程序,即 Internet Security 或 Antivirus,它会阻止您 PC 上的多个端口。
回答by Sophit
I've seen this message when your service throws an unhandled exception, so check that.
当您的服务抛出未处理的异常时,我已经看到了这条消息,所以请检查一下。