Fixes

Fix: The trust relationship between this workstation and the primary domain failed

Why a domain-joined Windows PC stops accepting domain logins, and how to repair the secure channel without rejoining the domain.

A domain-joined PC refuses to log you in and shows:

The trust relationship between this workstation and the primary domain failed.

Why it happens

Every domain-joined computer has a machine account in Active Directory with its own password, which the computer and a domain controller use to trust each other (the “secure channel”). The error appears when the two copies of that password stop matching. Common causes:

  • The PC was restored from a snapshot or backup, or a VM was rolled back.
  • The PC was powered off or off the network for a long time.
  • The computer object was deleted, reset or duplicated in Active Directory.
  • The PC’s clock is far out of sync with the domain.

Before you start

Sign in with a local administrator account (use .\Administrator or PCNAME\username on the login screen). Check these two things first, because they cause the same symptoms:

# DNS must point at your domain controller, not a public resolver
ipconfig /all

# Clock must be close to the domain controller's (within a few minutes)
w32tm /query /status

Fix 1: Repair the secure channel (try this first)

Open PowerShell as administrator and run:

Test-ComputerSecureChannel -Verbose

If it returns False, repair it with a domain account that is allowed to reset computer accounts:

Test-ComputerSecureChannel -Repair -Credential (Get-Credential)

Enter the domain admin credentials when prompted, then restart the PC and log in with a domain account.

Fix 2: Reset the machine password

If Fix 1 fails, reset the password directly against a domain controller (replace DC01 with yours):

Reset-ComputerMachinePassword -Server DC01 -Credential (Get-Credential)

Restart the PC afterwards.

Fix 3: Rejoin the domain (last resort)

  1. Log in as local administrator.
  2. Open System Properties and change the PC to a workgroup, then restart.
  3. In Active Directory Users and Computers, find the old computer object and reset it (right-click, Reset Account), or delete it if you are sure it is not needed.
  4. Join the PC back to the domain and restart.

Rejoining creates a new machine account, so check that the PC ends up in the right organisational unit and still receives the right Group Policy.

Check that it worked

Test-ComputerSecureChannel -Verbose
nltest /sc_verify:yourdomain.local

Both should report that the secure channel is healthy. Then log in with a domain account.

How to avoid it

Do not restore domain-joined VMs from old snapshots without planning for this, and keep PC clocks synced to the domain.