FIX: No connection could be made because the target machine actively refused it

“Could not connect to net.tcp://localhost:1500/policy” the basics.

After all the hassle with ADFS and the WAP servers that had been on too long. I got this error message on top after a restart of the ADFS server.

“TCP error code 10061: No connection could be made because the target machine actively refused it”

This error message also took a while before I had found it out.

I encountered this error message because I used a PowerShell cmdlet for ADFS. This does not mean that this cannot solve the problem at other times.

No idea if it only occurs on Windows Servers, but my solution is for a Windows Device only.


Lets fix “The connection attempt lasted for a time span“.

The message comes up because your firewall is blocking something. As you can see in the error message: “net.tcp://localhost:1500/policy”. Your connection tries to go over port 1500, but the server blocks this on purpose: “No connection could be made because the target machine actively refused it”.

In my situation I turned off the firewall to see if this was my issue. In a production environment you can do that as well temporarily, but make sure to turn it on again.

To turn off the Windows Firewall with PowerShell use this cmdlet:

Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False

To turn off the Windows Firewall temporarily in the GUI:

  1. Go to start and search for Control Panel.
  2. Search for Firewall.
  3. Open Turn Windows Defender Firewall on or off in the left menu.
  4. Select Turn off Windows Defender Firewall (not recommended).
TCP error code 10061: No connection could be made because the target machine actively refused it
TCP error code 10061: No connection could be made because the target machine actively refused it.

Try to make a connection again.


Summary

Do you have a different solution, or do you have feedback, or other ideas? Let me know in the comments.


A little extra

This post contains PowerShell. Would you like to learn the basics better? I have created a new website to learn basic PowerShell in an ’emulator’ environment.
Click here to go learn Basic PowerShell.


The complete error message

should someone Googling on another part of the error message:

"get-adfsendpoint : Could not connect to net.tcp://localhost:1500/policy. The connection attempt lasted for a time span

of 00:00:02.0781669. TCP error code 10061: No connection could be made because the target machine actively refused it

[::1]:1500.

At line:1 char:1

+ get-adfsendpoint

+ ~~~~~~~~~~~~~~~~

+ CategoryInfo          : OpenError: (:) [Get-AdfsEndpoint], EndpointNotFoundException

+ FullyQualifiedErrorId : Could not connect to net.tcp://localhost:1500/policy. The connection attempt lasted for

a time span of 00:00:02.0781669. TCP error code 10061: No connection could be made because the target machine acti

vely refused it [::1]:1500. ,Microsoft.IdentityServer.Management.Commands.GetEndpointCommand"

Published by

Bas Wijdenes

My name is Bas Wijdenes and I work as a PowerShell DevOps Engineer. In my spare time I write about interesting stuff that I encounter during my work.

2 thoughts on “FIX: No connection could be made because the target machine actively refused it”

  1. (First sorry for my bad English, i am French)

    For me,
    Just stop and retart the “Windows Internal Database” Services in the services.msc solve the problem.

    1. Check on ADFS Server, check Active Directory Federation Services status. If This service cannot started, change the account on his property.

Leave a Reply

Your email address will not be published. Required fields are marked *