I noticed after a recent update to Windows 2019, our lone server running Active Directory, that several related SQL Server services were no longer starting.
After researching each of those errors, I was able to get them running, leaving SQL Server Agent as the only one left to troubleshoot. I can start it manually, it runs for 10 seconds, then shuts down.
After researching, things I've tried:
- SERVICES > SQL SERVER AGENT > LOG ON, I changed this to Local System Account and ticked Allow Service To Interact With Desktop
- SERVICES > SQL SERVER AGENT > GENERAL, I changed Startup Type to Automatic (Delayed Start)
- SERVICES > SQL SERVER AGENT > Recovery > First Failure, I set to restart the service
- SERVICES > SQL SERVER AGENT > Recovery > Second Failure, I set to restart the service
Contents of SQLAGENT.OUT
2023-06-15 09:25:53 - ? [508] Logging SQL Server Agent messages in file 'E:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log\SQLAGENT.OUT'.
2023-06-15 09:25:53 - ? [000] Event Global\sqlserverRecComplete opened
2023-06-15 09:25:53 - ? [100] Microsoft SQLServerAgent version 15.0.2101.7 (X64 unicode retail build) : Process ID 8028
2023-06-15 09:25:53 - ? [495] The SQL Server Agent startup service account is XXX\SA200$.
2023-06-15 09:25:53 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:25:54 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:25:55 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:25:56 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:25:57 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:25:58 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:25:59 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:26:00 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:26:01 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:26:02 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:26:03 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:26:04 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:26:05 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:26:06 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:26:07 - ! [150] SQL Server does not accept the connection (error: 776). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2023-06-15 09:26:07 - ! [000] Unable to connect to server '(local)'; SQLServerAgent cannot start
2023-06-15 09:26:07 - ! [298] SQLServer Error: 776, SQL Server Network Interfaces: The token supplied to the function is invalid [SQLSTATE HY000]
2023-06-15 09:26:07 - ! [298] SQLServer Error: 776, Cannot generate SSPI context [SQLSTATE HY000]
2023-06-15 09:26:07 - ! [382] Logon to server '(local)' failed (DisableAgentXPs)
2023-06-15 09:26:07 - ? [098] SQLServerAgent terminated (normally)
Any help would be greatly appreciated
Additional Info
In terms of what may have influenced this behaviour, we had a catastrophic failure of the internet telephone line at the premises the day before. The quickest solution was to swap out the existing domestic router with a new one, which uses a sim card / 4G connection. The new router was given same IP address as previous one and its DHCP server was set up with same scope.
This then led me down a new rabbit hole, explaining how an SSPI > SPN error may have come about
article on Cannot Generate SSPI context
result of SQLCHECK...
Suggested SPN Exists Status
-------------------------------- ------ ---------------------------------------------
MSSQLSvc/SA200.ad.redacted.net:1433 False SPN is on the wrong account: Administrator, CN=Administrator,CN=Users,DC=ad,DC=redacted,DC=net
MSSQLSvc/SA200:1433 False SPN does not exist.
MSSQLSvc/SA200.ad.redacted.net False SPN is on the wrong account: Administrator, CN=Administrator,CN=Users,DC=ad,DC=redacted,DC=net
MSSQLSvc/SA200 False SPN does not exist.
I suspect this SPN issue could be down to me initially using the wrong solution to fix the SQLSERVER service - I altered the log on as to local service which I think may cause the above SPN issue. All I needed do was select delayed start. I'll try and set the SQLSERVER service back to log on as NT AUTHORITY/Network Service tonight and re-run SQLCHECK to see if it solves the SPN issue
UPDATE 22nd July 2023
Added 2 missing SPN's using SETSPN -s ...
SETSPN -s MSSQLSvc/SA200 (computername)
SETSPN -s MSSQLSvc/SA200:1433 (computername)
the 2 other SPN's I cant seem to remove and add back in...
MSSQLSvc/SA200.ad.redacted.net
MSSQLSvc/SA200.ad.redacted.net:1433
I can remove them with SETSPN -d but when I try to add either back in, it tells me duplicates detected