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

Troubleshooting Guide: SQL Server Error 8316 – Cannot Open Registry Key ‘HKLM%ls’

Why This Error Happens

This error occurs when the SQL Server service account lacks sufficient permissions to read or write to the specific registry hive path reserved for performance counter definitions, typically under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\...\Performance. It can also result from a corrupted or missing registry key caused by an incomplete SQL Server installation, a failed patch/update, or third-party security software stripping registry permissions. In some cases, Windows Server 2025’s stricter default ACL inheritance settings cause the service account to lose access after an OS upgrade.

Step-by-Step Resolution Guide

Step 1: Verify the SQL Server Service Account

  • Open Services.msc and confirm which account is running the SQL Server (MSSQLSERVER) service.
  • Note the exact account name (e.g., NT Service\MSSQLSERVER or a domain service account).
  • Cross-check this against the account configured in SQL Server Configuration Manager.

Step 2: Grant Registry Permissions Manually

  • Open regedit.exe as Administrator.
  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL17.MSSQLSERVER\Performance (adjust instance name/version as needed).
  • Right-click the key, select Permissions, and add the SQL Server service account with Full Control.
  • Repeat this for the parent key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER\Performance.

Step 3: Rebuild Performance Counters via Command Line

  • Open an elevated Command Prompt.
  • Navigate to the Binn folder: cd "C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn".
  • Run unlodctr MSSQLSERVER to remove the corrupted counter definitions.
  • Run lodctr perf-MSSQLSERVERsqlctr.ini to reload fresh counter definitions from the installation files.

Step 4: Restart SQL Server Services

  • Restart the SQL Server (MSSQLSERVER) service and the Windows Management Instrumentation (WMI) service via Services.msc.
  • Alternatively, run net stop MSSQLSERVER && net start MSSQLSERVER from an elevated Command Prompt.
  • Check the SQL Server Error Log immediately after restart for a repeat of Error 8316.

Alternative or Verification Steps

  • Open Performance Monitor (perfmon.exe), add a counter, and search for “SQL Server:General Statistics”—if it appears in the list, the fix was successful.
  • If the issue persists, run lodctr /R as Administrator to fully rebuild the entire Windows performance counter registry structure from scratch, then repeat Step 4.