Trust relationship failed is the sign-in error that turns a perfectly healthy domain PC into a locked door: the user types the right password and Windows answers that the trust relationship between this workstation and the primary domain failed. The good news is that you rarely need to remove the machine from the domain. Here are five proven fixes, in the order that wastes the least time, using only PowerShell and tools built into Windows.
What the Trust Relationship Failed Error Really Means
Every domain-joined computer has its own account in Active Directory and a password that only it and the domain controllers know. That password builds the secure channel the Netlogon service uses to authenticate the machine. When the copy on the computer no longer matches the copy in Active Directory, the secure channel cannot be built and the trust relationship failed message appears at sign-in.
Microsoft explains the mechanism in its article on resetting a machine account password with Netdom.exe. Each Windows computer keeps a password history with the current and the previous password. If the sequence of password changes exceeds two changes, the two sides can no longer talk, and you get errors such as Access Denied. By default, domain members submit a password change every 30 days, according to the Maximum machine account password age policy.

Common Causes of a Trust Relationship Failed Error
The error is a symptom, not a root cause, so it helps to know what usually produces a mismatch before you repair it:
- A virtual machine was reverted to an old snapshot or a backup was restored, so the computer holds an older password than Active Directory.
- The computer account was deleted, disabled or recreated in Active Directory while the PC was running.
- Two machines share the same computer name, so they keep overwriting each other’s password.
- The PC points at the wrong DNS server and cannot find a domain controller, or its clock is far out of sync with the domain.
- Machine account password changes were switched off or are failing, so the secure channel drifts over time.
Whatever the trigger, the quick test below tells you whether the trust relationship failed error really comes from a broken secure channel.
Before You Start: Sign In and Confirm the Trust Relationship Failed
Domain accounts will not work, so sign in with the local Administrator account or another local admin, and make sure the PC has network access to a domain controller. Open an elevated PowerShell window and run the test cmdlet. According to Microsoft, Test-ComputerSecureChannel returns True when the channel works and False when it does not, and the Verbose switch adds detail:
Test-ComputerSecureChannel -VerboseIf the answer is False, the trust relationship failed for real and you can continue. If it is True but users still cannot sign in, look at DNS, time and user account problems instead, because the machine account is fine. Note that this cmdlet only works on domain member computers: on a domain controller it returns false positive errors, and Microsoft points to netdom.exe or nltest.exe there.
Fix 1: Correct DNS and Time First
This is the cheapest fix and it solves more trust relationship failed cases than people expect. The workstation must use your domain DNS servers, not a router or a public resolver. Check what the PC is using and whether it can find a domain controller:
Get-DnsClientServerAddress -AddressFamily IPv4
nltest /dsgetdc:corp.contoso.com
w32tm /query /statusReplace corp.contoso.com with your own domain. If DNS points at the wrong server, correct it, run ipconfig /flushdns, and test the secure channel again. If the clock is far from the domain controller time, fix the time source first, because Kerberos and the secure channel both depend on it.
Fix 2: Repair the Secure Channel With Test-ComputerSecureChannel -Repair
If the trust relationship failed even with healthy DNS, let Windows rebuild the channel. The Repair parameter removes and then rebuilds the channel established by the Netlogon service. You must be a member of the local Administrators group, and you pass an account that is allowed to reset the computer account in the domain:
Test-ComputerSecureChannel -Repair -Credential (Get-Credential)Enter a domain account such as CORP\admin01 when prompted. Then confirm the result with the plain test again. If it returns True, restart the PC and ask the user to sign in with the domain account.

Fix 3: Reset the Machine Account Password With PowerShell
When the repair switch is not enough and the trust relationship failed message keeps coming back, change the machine account password directly. Microsoft describes Reset-ComputerMachinePassword as the cmdlet that changes the password the computer uses to authenticate to the domain controllers. You can name a domain controller and the credentials to use:
Reset-ComputerMachinePassword -Server "DC01" -Credential CORP\admin01Code language: JavaScript (javascript)PowerShell prompts for the password of the account you typed. The command produces no output on success, so verify it with Test-ComputerSecureChannel afterwards. The cmdlet can also run against a remote PC with Invoke-Command, but remember that a remote command needs a working path to the machine, which is not always the case when the trust relationship failed.
Fix 4: Use netdom resetpwd When Cmdlets Fail
The older command-line route is still valid. Microsoft documents netdom resetpwd for machine accounts, and says the procedure applies to any Windows machine account even though it is most often used on domain controllers. You must run it locally on the affected computer, with administrative permission on the machine and on its computer account object in Active Directory:
netdom resetpwd /s:DC01 /ud:CORP\admin01 /pd:*Here /s is the domain controller used to set the password, /ud is the account in domain\user format, and /pd:* makes netdom prompt for the password instead of putting it on the command line. Microsoft says the tool changes the local secret and writes the change to the computer account on the domain controller at the same time, then restart the computer. If netdom is not found on a workstation, install the AD DS tools from RSAT first; our guide on how to install RSAT on Windows 11 shows the quick way.
Fix 5: Check and Reset the Channel With nltest
Nltest is the lightweight diagnostic option. In the Nltest reference, /sc_query reports the state of the secure channel and the domain controller that was queried, and /sc_reset removes and rebuilds the channel, which needs administrative credentials:
nltest /sc_query:corp.contoso.com
nltest /sc_reset:corp.contoso.comNltest alone will not clear a trust relationship failed error caused by a real password mismatch, but it is a quick way to see which domain controller the PC talks to and whether the channel recovers after a DNS or routing change. For a genuine mismatch, go back to Fix 3 or Fix 4.
Verify the Fix and Sign In Again
Test-ComputerSecureChannel -Verbose
nltest /sc_query:corp.contoso.comOnce the trust relationship failed message is gone, you want True from the first command and a connection status of NERR_Success from the second. Restart the computer so every service picks up the new password, then sign in with a domain account that has not been used on the PC before, to rule out stale cached credentials.

Last Resort: Rejoin the Domain
If every repair fails and the trust relationship failed message returns, for example because the computer account was deleted, rejoin the machine. It is slower, because it needs two restarts, and it is the option the five fixes above are designed to avoid. Use a local admin session and a domain account that may join computers:
Remove-Computer -UnjoinDomainCredential CORP\admin01 -WorkgroupName "TEMP" -Restart
# after the restart, sign in locally and run:
Add-Computer -DomainName corp.contoso.com -Credential CORP\admin01 -RestartCode language: PHP (php)Check the computer object in Active Directory afterwards. Related cleanup, such as removing old BitLocker recovery passwords from Active Directory, is easier when the computer name stays the same.
How to Prevent the Trust Relationship Failed Error
- Leave machine account password changes enabled. Microsoft’s guidance for Disable machine account password changes is not to enable that setting, and to keep the 30-day default.
- Do not revert domain-joined VMs to old snapshots without a plan. If you must, run the Test-ComputerSecureChannel check right after.
- Use unique computer names, and clean up stale computer objects instead of reusing names blindly.
- For non-persistent VDI, Microsoft suggests planning password changes for maintenance windows and running
nltest /sc_change_pwd:<domain>to trigger an update. - Monitor the Netlogon events on domain controllers. Event 5722 reports a failed session setup from a computer, and it can point at a machine account password out of sync.
Read more: How To Windows Server 2016 Metadata Cleanup Best Way
Read more: How to Easy Install RSAT on Windows 11
What does “trust relationship between this workstation and the primary domain failed” mean?
It means the computer account password stored on the PC no longer matches the one in Active Directory, so the Netlogon secure channel cannot be established and domain sign-in is refused.
Do I have to remove the computer from the domain to fix a trust relationship failed error?
Usually not. Test-ComputerSecureChannel -Repair, Reset-ComputerMachinePassword or netdom resetpwd reset the machine account password without unjoining. Rejoining is the last resort.
How do I sign in when the trust relationship failed?
Use a local administrator account. Domain accounts cannot authenticate while the secure channel is broken, so a local account is needed to run the repair commands.
How often does a domain computer change its password?
By default every 30 days, according to Microsoft. The Maximum machine account password age policy can change the interval, but Microsoft recommends staying at about 30 days.
What does Test-ComputerSecureChannel return?
It returns True if the secure channel works correctly and False if it does not. Add the Verbose parameter for detailed messages, and use Repair to try to rebuild a broken channel.
References
Microsoft Learn: Test-ComputerSecureChannel
Microsoft Learn: Reset-ComputerMachinePassword
Microsoft Learn: Reset domain controller’s password with Netdom.exe
Microsoft Learn: Nltest
Microsoft Learn: Domain member: Maximum machine account password age
Microsoft Learn: Domain member: Disable machine account password changes





