Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
Windows Server

Troubleshoot Windows service crashes on a server

Find why a Windows service keeps stopping: read Service Control Manager events, rule out memory and disk, set recovery actions with sc.exe and capture dumps.

CloudSat teamNovember 18, 20266 min read
Abstract illustration of a row of interlocking gears with one slipped out of line, above a pulse-like log trace
On this pageStep 1: find which service stopped, and how

A Windows service that "randomly" stops is rarely random. Every unexpected stop is recorded by the Service Control Manager, and the event usually points to one of four causes: a bug in the service itself, a dependency that went down first, an account that can no longer log on, or a server that ran out of memory or disk. This guide follows that order: find the event, read it, rule out the machine, then keep the service alive with recovery actions while you fix the root cause.

Step 1: find which service stopped, and how

The System log holds the Service Control Manager's side of the story. This query pulls the events that matter, newest first:

Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Service Control Manager'; Id=7000,7009,7011,7023,7024,7031,7034,7038} -MaxEvents 30 |
    Format-Table TimeCreated, Id, Message -Wrap
Event ID What it means Where to look next
7031 The service terminated unexpectedly, and a recovery action is configured The Application log at the same time
7034 The service terminated unexpectedly, with no recovery action The Application log; add recovery (step 4)
7023 The service stopped with a Windows error The error text in the message
7024 The service stopped with its own error code The vendor's documentation
7000 The service failed to start Executable path, permissions, dependencies
7009 Timeout waiting for the service to connect Slow start or a hung dependency
7011 Timeout waiting for a response to a control request A service that hangs instead of crashing
7038 The service could not log on with its configured account A changed or expired password

A crash leaves a second trace in the Application log, usually event 1000 (Application Error) or 1026 (.NET Runtime), logged a moment before the Service Control Manager notices:

Get-WinEvent -FilterHashtable @{LogName='Application'; Id=1000,1026} -MaxEvents 20 |
    Format-List TimeCreated, ProviderName, Message

Step 2: read what the events say

The faulting module

Event 1000 names the faulting application and the faulting module. If the module belongs to the service itself, you are looking at a bug, often triggered by a recent update of that software. If it is a third-party DLL, such as a security or monitoring agent that injects itself into other processes, suspect that agent first. A crash in a core Windows module like ntdll.dll usually still means the application corrupted its own memory, not that Windows is broken. Compare the first crash with your change history: Get-HotFix | Sort-Object InstalledOn -Descending shows recent Windows updates, and your deployment log shows the rest.

Services that share a process

Many built-in services run inside svchost.exe. On machines with more than about 3.5 GB of RAM, Windows gives most of them their own process; on smaller servers it groups several services into one, so one failing service can take its neighbors down with it. Check who shares a process:

tasklist /svc /fi "imagename eq svchost.exe"

Logon failures

Event 7038 means the account configured for the service no longer works, usually because its password was changed or expired. Update the password on the Log On tab in services.msc, or move the service to a virtual or managed service account if the software supports one, so there is no password to expire.

Timeouts

By default the Service Control Manager waits about 30 seconds for a service to report that it started. Slow starters fail with event 7009 and error 1053, "The service did not respond to the start or control request in a timely fashion". First try delaying the start until the boot settles:

sc.exe config MyService start= delayed-auto

If the service still needs longer, a DWORD named ServicesPipeTimeout under HKLM\SYSTEM\CurrentControlSet\Control, in milliseconds, raises the limit for every service after a restart. Treat it as a last resort, since it also hides genuinely hung services.

Dependencies

A service stops when a service it depends on stops. List the chain before blaming the service:

sc.exe qc MyService
Get-Service -Name MyService -RequiredServices

Step 3: rule out the machine

When several unrelated services fail around the same time, look at the server rather than the services:

  • Memory. Get-Counter '\Memory\Available MBytes' shows free memory, and event 2004 from Resource-Exhaustion-Detector in the System log means Windows ran low on virtual memory; its message names the processes using the most. A page file that is too small makes this worse.
  • Disk. Services that cannot write logs or temp files crash in odd ways. A full C: drive is a classic cause; see freeing and extending disk space on Windows.
  • System files. If built-in services crash with errors in Windows modules after a failed update, check the image with DISM and SFC.

If memory is simply too tight for the workload, add RAM rather than tuning around it; a CloudSat server can move to a bigger plan from the console (resize a server).

Step 4: keep the service running while you investigate

Recovery actions tell Windows what to do when a service fails. The command line form is quick, with one quirk: each option needs a space after the equals sign. In Windows PowerShell, type sc.exe, because plain sc is an alias for Set-Content there.

sc.exe failure MyService reset= 86400 actions= restart/5000/restart/30000/restart/60000
sc.exe failureflag MyService 1
sc.exe qfailure MyService

The first line restarts the service 5 seconds after the first failure, 30 seconds after the second and one minute after later ones, and resets the failure count after a day without failures (reset= is in seconds, delays in milliseconds). By default, recovery only runs when the service process dies. failureflag 1 also triggers it when the service stops itself with an error code. qfailure prints the result. The same settings live on the Recovery tab in services.msc.

A restart policy hides crashes from users, not from you. Keep watching events 7031 to see how often it fires.

Step 5: capture a crash dump

When the vendor or your developers need more than an event, have Windows Error Reporting save a full dump of the crashing process. Use the executable name of the service:

$key = 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\myservice.exe'
if (-not (Test-Path $key)) { New-Item -Path $key -Force | Out-Null }
Set-ItemProperty -Path $key -Name DumpFolder -Value 'C:\CrashDumps' -Type ExpandString
Set-ItemProperty -Path $key -Name DumpType -Value 2 -Type DWord
Set-ItemProperty -Path $key -Name DumpCount -Value 5 -Type DWord

DumpType 2 means a full dump, which is as large as the process's memory, so point it at a drive with room and keep DumpCount low. The service account must be able to write to the folder. Without a DumpFolder, dumps of service processes land under that account's profile, for example %WINDIR%\System32\Config\SystemProfile for services running as Local System. Delete the key once you have what you need.

FAQ

Why does sc failure return a usage message instead of working?

Almost always a missing space after an equals sign (reset= 86400, not reset=86400), or sc typed in Windows PowerShell, where it means Set-Content. Use sc.exe and keep the spaces.

Should I restart crashed services with a scheduled task?

No. Recovery actions are built into the Service Control Manager, react within seconds and log every attempt. A scheduled task polls, misses short crashes and adds another moving part.

The service crashes only under load. Where do I start?

Watch memory and handle counts of its process over time with Performance Monitor, or Get-Process -Name myservice | Select-Object WorkingSet64, HandleCount in a loop. Steady growth before each crash points to a leak in the service, which a dump from step 5 will help its developers confirm.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.