How to fix Error 1459 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 1459 — Database Mirroring Metadata Access Error

Why This Error Happens

Error 1459 typically occurs when the database mirroring metadata stored in the system catalogs becomes inconsistent, corrupted, or is left in a stale state after an improper failover, abrupt service termination, or a botched mirroring removal attempt. This can also happen when the mirroring endpoint is unreachable, the service account lacks the necessary permissions on the endpoint, or the mirroring session state tables (sys.database_mirroring) were not properly updated during a topology change. In some cases, a mismatch between the principal and mirror server’s internal mirroring GUIDs triggers this metadata validation failure.

Step-by-Step Resolution Guide

Step 1: Verify Current Mirroring State

  • Open SQL Server Management Studio (SSMS) and connect to the affected instance.
  • Run the following query to inspect the mirroring metadata:
  SELECT database_id, mirroring_state_desc, mirroring_role_desc, mirroring_partner_instance 
  FROM sys.database_mirroring 
  WHERE mirroring_guid IS NOT NULL;
  • Note the mirroring_state_desc value — if it shows SUSPENDED, DISCONNECTED, or NULL unexpectedly, this confirms metadata inconsistency.

Step 2: Forcefully Remove the Broken Mirroring Configuration

  • On the affected database, run:
  ALTER DATABASE [YourDatabaseName] SET PARTNER OFF;
  • If this command itself fails with Error 1459, restart the SQL Server service via services.msc or PowerShell:
  Restart-Service -Name 'MSSQLSERVER' -Force
  • Re-attempt the SET PARTNER OFF command immediately after the service restarts, as a fresh service start often clears cached mirroring state.

Step 3: Validate and Clean the Endpoint Configuration

  • Check the mirroring endpoint status on both principal and mirror servers:
  SELECT name, state_desc, port, encryption_algorithm_desc 
  FROM sys.database_mirroring_endpoints;
  • Ensure the endpoint is STARTED and listening on the expected port (default 5022) by confirming with:
  Test-NetConnection -ComputerName <MirrorServerName> -Port 5022
  • If the endpoint is corrupted, drop and recreate it:
  DROP ENDPOINT Mirroring_Endpoint;
  CREATE ENDPOINT Mirroring_Endpoint
  STATE = STARTED
  AS TCP (LISTENER_PORT = 5022)
  FOR DATABASE_MIRRORING (ROLE = PARTNER);

Step 4: Reconfigure Mirroring from Scratch

  • Take a fresh full backup and transaction log backup of the principal database.
  • Restore both to the mirror server using WITH NORECOVERY.
  • Re-establish the partnership on both instances:
  -- On Mirror
  ALTER DATABASE [YourDatabaseName] SET PARTNER = 'TCP://PrincipalServer:5022';

  -- On Principal
  ALTER DATABASE [YourDatabaseName] SET PARTNER = 'TCP://MirrorServer:5022';

Alternative or Verification Steps

  • After reconfiguration, confirm healthy status via SELECT mirroring_state_desc FROM sys.database_mirroring WHERE database_id = DB_ID('YourDatabaseName'); — it should return SYNCHRONIZED.
  • If mirroring continues to fail, consider migrating to Always On Availability Groups, which is the Microsoft-recommended replacement for legacy database mirroring in SQL Server 2025.