Troubleshooting Guide: SQL Server Error 5805 – “Too Few Locks Specified”
Why This Error Happens
This error occurs when the locks configuration option in SQL Server has been manually set to a value below the minimum threshold required for the engine to start and operate safely. SQL Server 2025 requires a baseline number of lock structures to manage concurrency, and setting this value too low (often during an attempt to manually tune memory) prevents the Lock Manager from initializing. This is typically caused by a misconfigured sp_configure 'locks' value or a legacy startup parameter carried over from a server migration or restore.
Step-by-Step Resolution Guide
Step 1: Verify the Current Locks Configuration
- Open SQL Server Management Studio (SSMS) or connect via
sqlcmdusing the Dedicated Administrator Connection (DAC) if the instance won’t start normally. - Run the following query to check the current setting:
EXEC sp_configure 'locks'; - Note the
config_valueandrun_valuecolumns; a non-zero value below the system minimum (typically 5000) is the likely culprit.
Step 2: Reset the Locks Value to Dynamic (Default)
- Execute the following T-SQL commands to restore dynamic lock management, which is the recommended setting for SQL Server 2025:
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;EXEC sp_configure 'locks', 0; RECONFIGURE;- Setting the value to
0allows SQL Server to dynamically allocate and de-allocate lock memory as needed, preventing manual threshold errors.
Step 3: Start the Instance Using Minimal Configuration (If Service Won’t Start)
- If the SQL Server service fails to start due to this error, open the Services app (
services.msc) on Windows Server 2025/Windows 11. - Locate the SQL Server service, right-click, and navigate to Properties.
- Temporarily add the startup parameter
-f(minimal configuration) in the Startup Parameters tab to force the engine to bypass the invalid locks setting. - Start the service, apply the fix detailed in Step 2, remove the
-fflag, and restart the service normally.
Step 4: Check for Registry or Startup Script Overrides
- Navigate to
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQLServer\Parametersin the Windows Registry. - Inspect for any legacy
-Ttrace flags or startup scripts that might be re-applying an oldlocksvalue on every restart. - Remove or correct any deprecated parameters found in this key.
Alternative or Verification Steps
- Verify the Fix: Restart the SQL Server service via
services.mscornet start MSSQLSERVERand confirm the instance comes online without Error 5805 appearing in the SQL Server Error Log (located atC:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG). - Alternative Solution: If the configuration continues to revert, restore the
masterdatabase from a known-good backup taken prior to the configuration change, as a corruptedmasterdatabase can sometimes cause configuration values to stick incorrectly.