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

Why This Error Happens

SQL Server 2025 Error 3112 occurs because single-user mode is designed to permit only one connection to the instance, and that connection is almost always reserved by SQL Server’s internal system processes or the first administrative session that connects. When you attempt to restore a user database, the RESTORE command often requires a second connection (or the existing connection is already consumed by SSMS’s background processes like IntelliSense), causing SQL Server to reject the operation because it exceeds the single-connection limit. This is compounded by the fact that in single-user mode, only members of the sysadmin role can connect, and any orphaned session—even an idle one—blocks all subsequent restore attempts.

Step-by-Step Resolution Guide

Step 1: Start SQL Server in Single-User Mode Correctly

  • Stop the SQL Server service via SQL Server Configuration Manager or net stop MSSQLSERVER.
  • Start the service with the -m startup parameter using a dedicated client application name to avoid SSMS interference: NET START MSSQLSERVER /m"SQLCMD".
  • This reserves the single connection slot specifically for SQLCMD, preventing SSMS background tasks from consuming it.

Step 2: Connect Using SQLCMD Instead of SSMS

  • Open Command Prompt as Administrator on Windows Server 2025 / Windows 11.
  • Connect using the matching client name: sqlcmd -S localhost -E -N -C.
  • Avoid opening SSMS simultaneously, as its Object Explorer and IntelliSense features silently open multiple background connections that will trigger Error 3112.

Step 3: Execute the Restore Command Directly

  • Run the restore command immediately after connecting, without executing any other queries first:
  • RESTORE DATABASE [YourDatabaseName] FROM DISK = 'C:\Backups\YourDatabase.bak' WITH REPLACE;
  • Follow immediately with GO to execute, ensuring no other session has been initiated in parallel.

Step 4: Verify No Orphaned Sessions Exist

  • Before retrying, check for lingering connections by querying sys.dm_exec_sessions if you can briefly get a connection (or restart the service again to reset the state).
  • If the restore still fails, restart the SQL Server service again to clear any hung session, then immediately reconnect via SQLCMD only.

Alternative or Verification Steps

  • Verify the fix by confirming the database state changes to ONLINE by running SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabaseName'; after taking the server out of single-user mode (ALTER DATABASE [master] SET MULTI_USER; equivalent via restart).
  • As an alternative, use the dedicated administrator connection (DAC) by prefixing your SQLCMD connection with ADMIN: (e.g., sqlcmd -S ADMIN:localhost -E), which bypasses the single-user connection limit entirely and often resolves Error 3112 without needing to restart the service in -m mode.