Blog Post

SQL Server Support Blog
3 MIN READ

SQL Server Agent fails to start on Windows Server 2022 due to Application event log policy setting

cleng-ms's avatar
cleng-ms
Icon for Microsoft rankMicrosoft
May 17, 2023

Problem

 

A customer recently reported that they tried to build a SQL Server running on Windows Server 2022 but found that the SQL Server Agent failed to start. Below is the error popup when starting the SQL Server Agent in SQL Server Configuration Manager.

There are no other errors in ERRORLOG, SQLAGENT, and Windows event logs.

 

We worked with the customer and collected TTD (Time Travel Debugging) traces on several services. Finally, we found out the cause of the problem.

 

Cause

 

In Windows, there is a group policy named “Configure log access” under “Computer Configuration” -> “Administrative Templates” -> “Windows Components” -> “Event Log Service” -> “Application”. You can use this policy to set an SDDL (Security Descriptor Definition Language) string to grant users access to the Application event log. An example of the SDDL string that can be used here is “O:BAG:SYD:(A;;0xf0005;;;SY)(A;;0x7;;;BA)(A;;0x1;;;S-1-5-32-573)”, for which the parts in the 3 parentheses grant the following accesses:

  • (A;;0xf0005;;;SY) grants Full Control to the Local System account.
  • (A;;0x7;;;BA) grants read and write access to the Built-in Administrators group.
  • (A;;0x1;;;S-1-5-32-573) grants read access to the Event Log Readers group.

 

 

 

However, there was a problem in old versions of Windows up to Windows Server 2019 where this policy had not been strictly enforced. As a result, a user account not granted write access to the Application event log by this policy could still write to the said event log. In the versions of Windows released after Windows Server 2019, this problem has been fixed. Therefore, the restriction of access to the Application event log by this policy is correctly enforced. This has caused the problem of SQL Server Agent not starting on Windows Server 2022 in our case.

 

Upon service start, the SQL Server Agent calls a Windows API to register its own event source to the Application event log, which requires write access to it. Because the SQL Server Agent runs under an account that is not granted write access to the Application event log by the policy, the API call fails and SQL Server Agent quits itself because of the error.

 

Solution

 

There are two ways to solve this problem:

  1. Set the “Configure log access” policy to “Not Configured” or “Disabled”.
  2. If you need to enable the “Configure log access” policy, then you need to grant both read and write access to the account used by the SQL Server Agent service by adding the SDDL string for that account. The additional SDDL string should start with A;;0x7;;; and end with the SID string for that account. You should also add parentheses around the SDDL string.
    As an example, the SID for the “NT Service\SQLSERVERAGENT” is S-1-5-80-344959196-2060754871-2302487193-2804545603-1466107430. The SDDL string that needed to be added is (A;;0x7;;;S-1-5-80-344959196-2060754871-2302487193-2804545603-1466107430) . Below is the whole SDDL string after this addition:


O:BAG:SYD:(A;;0xf0005;;;SY)(A;;0x7;;;BA)(A;;0x1;;;S-1-5-32-573)(A;;0x7;;;S-1-5-80-344959196-2060754871-2302487193-2804545603-1466107430)



How to check if you are hitting the same problem

1. The SQL Server Agent fails to start, but there are no errors logged in ERRORLOG, SQLAgent logs and event logs

2. The “Configure log access” policy under “Computer Configuration” -> “Administrative Templates” -> “Windows Components” -> “Event Log Service” -> “Application” is enabled. You can check this policy by running gpedit.msc. 

 

Other known issues with SQL Server agent not starting

 

https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/startup-shutdown/agent-service-fails-start-stand-alone-server

https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/startup-shutdown/sql-server-agent-crashes-upon-start


Thank you!!

Updated May 23, 2023
Version 2.0

8 Comments

  • sidsamarth, please check if the registry setting below exists on your machine.

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Eventlog\Application\
    CustomSD REG_SZ xxxx

     

    This is the local registry setting for controlling Application Eventlog access permission. If it exists, either delete it, or change the SDDL string to grant READ and WRITE access to the SQL Agent service account.

    Please also check the following document on this registry setting.
    Set event log security locally or via Group Policy - Windows Server | Microsoft Learn

  • sidsamarth's avatar
    sidsamarth
    Copper Contributor

    ben-thul Thanks for the reply. I tried that earlier but couldn't find the Group Policy Object Editor Snap-In, I am assuming this may be down to it being the home edition. I am hoping there is still some work around for the home edition.

  • ben-thul's avatar
    ben-thul
    Copper Contributor

    sidsamarth- I'm on Windows 11 (Professional edition for full disclosure) and was able to find the group policy editor by doing Win-R -> mmc -> Add/Remove Snap-In... -> Group Policy Object Editor. Hopefully that works for you too.

  • sidsamarth's avatar
    sidsamarth
    Copper Contributor

    Hello! I am using windows 11 home edition and am not able to access local group policy editor. Is there any other way to change the configure log access, or some other way to fix this issue?

  • You are correct. In the actual case, we asked the customer to change their GPO. The intent of this article is to show where the setting should be changed and how, in GPO or in local group policy.

  • ben-thul's avatar
    ben-thul
    Copper Contributor

    I'm probably missing something, but if the setting was incorrect due to a GPO, would the manual fix that you suggest above be able to be applied? Either it would be non-durable (i.e. the GPO would overwrite the setting again some time after the manual change was applied) or it wouldn't be able to be applied at all.

  • ben-thul Most of the time the setting is from a GPO created by system administrators. It would not be correct for the SQL server installer or any other SQL components to change this kind of Windows system settings.

  • ben-thul's avatar
    ben-thul
    Copper Contributor

    Would it be possible to integrate this into the installer such that Agent works out of the box? Expecting everyone who is installing SQL on Win 2022 (which is going to be a growing number over time) to find this post and manually apply a fix feels bad.