No connection could be made because the target machine actively refused it 127.0.0.1:3446
"Actively refused it" means that the host sent a reset instead of an ack when you tried to connect. It is therefore not a problem in your code. Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port. This may be because it is not running at all or because it is listening on a different port.
Once you start the process hosting your service, try netstat -anb
(requires admin privileges) to verify that it is running and listening on the expected port.
update: On Linux you may need to do netstat -anp
instead.
You don't have to restart the PC. Restart IIS instead.
Run -> 'cmd'(as admin) and type "iisreset"
I got a similar error message like TCP error code 10061: No connection could be made because the target machine actively refused it in my current project. I find this 10061 error code cannot distinguish the case that the service endpoint is not started and the case that it is blocked by the firewall. Often, the firewall can be switched off, but the problem is still there.
You can test your code in the below two ways.
- Insert code to get time A that service is started and time B that client sends the request to the server. If B is earlier than A, it can cause this problem.
- Change your server port to another port that is also available in the system. You will find the same error code reported.
Above is my fix. It works on my machine. I hope it helps!