Why This Error Happens
Error 1457 during database mirroring synchronization typically occurs because the mirror session cannot establish a stable connection between the principal and mirror instances, often due to network latency, firewall blocking the endpoint port, or insufficient permissions on the mirroring endpoint login. It can also happen when the database mirroring endpoint is in a STOPPED state or when certificate-based authentication between instances has expired or is mismatched. In some cases, a corrupted transaction log backup chain prevents the mirror database from catching up, causing SQL Server to report a synchronization failure.
Step-by-Step Resolution Guide
Step 1: Verify the Mirroring Endpoint Status
- Run
SELECT * FROM sys.database_mirroring_endpoints;on both the principal and mirror instances. - Confirm the
state_desccolumn showsSTARTED; if not, runALTER ENDPOINT [Mirroring] STATE = STARTED;. - Check that the endpoint port (default 5022) matches on both servers.
Step 2: Check Firewall and Network Connectivity
- On Windows Server 2025 / Windows 11, open Windows Defender Firewall with Advanced Security.
- Create an inbound/outbound rule allowing TCP traffic on port 5022 for
sqlservr.exe. - Test connectivity using
Test-NetConnection -ComputerName <MirrorServerName> -Port 5022in PowerShell.
Step 3: Validate Login Permissions and Certificates
- Ensure the service account or certificate used for mirroring has
CONNECTpermission on the endpoint:GRANT CONNECT ON ENDPOINT::Mirroring TO [DOMAIN\ServiceAccount];. - If using certificates, confirm they haven’t expired via
SELECT name, expiry_date FROM sys.certificates;. - Re-establish the mirroring session using
ALTER DATABASE [YourDB] SET PARTNER RESUME;if the session was suspended.
Step 4: Re-sync the Mirror Database
- If the log chain is broken, take a fresh full backup and transaction log backup of the principal database.
- Restore both with
WITH NORECOVERYon the mirror instance. - Re-establish mirroring:
ALTER DATABASE [YourDB] SET PARTNER = 'TCP://MirrorServer:5022';.
Alternative or Verification Steps
- Confirm successful synchronization by checking SQL Server Management Studio > Database Properties > Mirroring page — status should read “Synchronized.”
- As an alternative, consider migrating to Always On Availability Groups, which offers improved diagnostics and resolves many legacy mirroring endpoint issues in SQL Server 2025.