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

Troubleshooting Guide: Error 3104 – RESTORE Cannot Operate on a Database Configured for Mirroring or Availability Groups

Why This Error Happens

This error occurs because SQL Server 2025 blocks standard RESTORE operations against any database that is currently participating in a Database Mirroring session or is a member of an Availability Group (AG). The restore engine detects the mirroring/AG metadata in the database header and refuses to proceed to prevent breaking synchronization between replicas or corrupting the log chain. This typically happens when an administrator attempts a routine restore without first removing the database from its high-availability configuration.

Step-by-Step Resolution Guide

Step 1: Identify the Database’s Current HA Configuration

  • Open SQL Server Management Studio (SSMS) and connect to the instance running on Windows Server 2025.
  • Run the following query to check mirroring/AG status:
  SELECT name, state_desc, is_mirroring_enabled 
  FROM sys.databases WHERE name = 'YourDatabaseName';
  • Check sys.availability_databases_cluster or the Always On Availability Groups node in SSMS Object Explorer to confirm AG membership.

Step 2: Remove the Database from Mirroring or the Availability Group

  • If mirroring is enabled, run:
  ALTER DATABASE [YourDatabaseName] SET PARTNER OFF;
  • If the database belongs to an Availability Group, remove it using:
  ALTER DATABASE [YourDatabaseName] SET HADR OFF;
  • Alternatively, use SSMS: right-click the Availability Group → Remove Database from Availability Group.

Step 3: Perform the Restore Operation

  • Once the database is detached from mirroring/AG, re-run the RESTORE command:
  RESTORE DATABASE [YourDatabaseName] 
  FROM DISK = 'C:\Backups\YourDatabaseName.bak' 
  WITH REPLACE, RECOVERY;
  • Ensure the backup file path is accessible and the SQL Server service account has read permissions on the folder (C:\Backups\).

Step 4: Re-establish High Availability (Optional)

  • After the restore completes successfully, re-add the database to the Availability Group using the Add Database to Availability Group Wizard in SSMS.
  • If using mirroring, reconfigure the partner and witness servers via ALTER DATABASE ... SET PARTNER = 'TCP://PartnerServer:5022'.

Alternative or Verification Steps

  • Verify the fix by querying sys.databases again — is_mirroring_enabled should return 0 and the database state should show ONLINE after the restore.
  • If removal from the Availability Group fails due to cluster quorum issues, use Failover Cluster Manager on Windows Server 2025 to confirm the WSFC role is healthy before retrying Step 2.