Fix ERROR_SERVICE_EXISTS (0x00000431) in Windows Server
This error pops up when you try to install or create a service that's already registered. We'll walk through clearing it out.
Quick Fix: 30 Seconds – Check and Stop the Service
Before you do anything else, open Services.msc or run this in PowerShell as admin:
Get-Service -Name "YourServiceName" -ErrorAction SilentlyContinueIf the service shows up, it's already there. If you just want to restart it, use:
Restart-Service -Name "YourServiceName"That solves nothing? Good. Read on.
Moderate Fix: 5 Minutes – Delete the Stale Service Entry
The culprit here is almost always an orphaned service entry. Maybe you uninstalled the app wrong, or a previous install left junk behind. Either way, we'll tear it out with sc.
Open Command Prompt as admin. Run:
sc query "YourServiceName"If it shows STATE: STOPPED (or anything), delete it:
sc delete "YourServiceName"If you get Access Denied, you're not running as admin. Fix that first.
No output? That means the service isn't in the SCM database – but the error still fires? Skip to the advanced fix.
Advanced Fix: 15+ Minutes – Registry Cleanup and System Restart
When sc delete fails silently or you still get the error, there's a ghost entry in the registry. Here's where we dig.
Step 1: Backup your registry. I've seen people hose their whole server skipping this. Export the key before you touch anything.
Step 2: Open Regedit as admin. Navigate to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ServicesStep 3: Find your service key. Hit Ctrl+F and type the service name. It'll be a subkey under Services. Right-click it and delete. Yes, really. That's it.
Step 4: Reboot the server. The SCM caches this stuff. A restart forces a fresh read from the registry. No reboot? Don't be surprised if the error comes back.
Step 5: Now install or create the service again. It'll work.
Real-world trigger: I've seen this constantly with third-party backup agents (Veeam, CommVault) that leave their service behind after an uninstall. Also common with custom .NET Windows Services where developers forget to call ServiceInstaller.Uninstall().Still stuck? Try these edge cases:
- Check for hidden services: Run
sc query state= all | find "YourServiceName"– sometimes they're in 'disabled' state and sc delete won't touch them. Usesc config "YourServiceName" start= demandfirst, then sc delete. - Use PowerShell's Remove-Service: Only on Server 2016+ and Windows 10+.
Remove-Service -Name "YourServiceName"– but if the registry key was already deleted, this errors out. - Corrupted SCM database: Extreme. Boot into Safe Mode, delete the service key in registry, reboot normally. Don't try this unless you're desperate – it's a last resort.
Wrap-up
This error is annoying but not dangerous. Start with sc delete. If that fails, hit the registry. Reboot. You're done. I've fixed this on Windows Server 2012 R2 through 2022 – same process every time.
Was this solution helpful?