Symptom
Windows could not start the SQL Server (MSSQLSERVER) service... error 3417or "service started and then stopped".- Applications report the instance is unreachable after a reboot, patch or storage change.
Step 1: read the real error
The service error is generic. The cause is in the ERRORLOG, usually in ...\MSSQLnn.INSTANCE\MSSQL\Log\ERRORLOG.
Find the path from the startup parameters (-e), in SQL Server Configuration Manager → service → Startup Parameters, or from the registry:
Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQLServer\Parameters'
Get-Content 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOG' -Tail 60
Also check the System and Application event logs (source MSSQLSERVER).
Step 2: match the cause
| ERRORLOG shows | Cause | Go to |
|---|---|---|
CREATE FILE encountered operating system error 3 ... tempdb.mdf | tempdb folder missing (new disk, lost drive letter, ephemeral disk) | Fix A |
FCB::Open failed ... master.mdf / error 17204, 17207 | master file missing, moved or no permission | Fix B |
Error: 3417 / master corrupt | master damaged | Fix C |
Operating system error 5 (Access is denied) | Service account lost folder rights | Fix D |
TDSSNIClient initialization failed / port in use | Port conflict or TLS certificate problem | Fix E |
| Nothing written at all | Wrong -e path, account can't log on, or the binaries are broken | Fix D, then event logs |
Fix A: tempdb path missing
Common on Azure/AWS VMs where tempdb sits on a temporary disk whose folder disappears after a deallocation.
- Create the folder again and grant the service SID rights:
New-Item -ItemType Directory D:\SQLTemp -Force
icacls D:\SQLTemp /grant "NT SERVICE\MSSQLSERVER:(OI)(CI)F"
- Start the service. If the drive itself is gone, start with minimal configuration and move tempdb:
net start MSSQLSERVER /f /mSQLCMD
sqlcmd -S . -E -Q "ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, FILENAME = 'E:\SQLTemp\tempdb.mdf'); ALTER DATABASE tempdb MODIFY FILE (NAME = templog, FILENAME = 'E:\SQLTemp\templog.ldf');"
net stop MSSQLSERVER
net start MSSQLSERVER
Repeat MODIFY FILE for each extra tempdb data file (temp2, temp3, ...). For ephemeral disks, add a startup script that recreates the folder before SQL Server starts.
Fix B: master files missing or moved
Check the -d (master data) and -l (master log) startup parameters point to files that exist. If someone moved them, correct the parameters in Configuration Manager. If a drive letter changed, restore the letter in Disk Management.
Fix C: master corrupt
- Rebuild the system databases from the setup media (this resets logins, jobs, configuration):
setup.exe /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS="CONTOSO\DBA-Admins" /SAPWD="<strong pwd>"
- Start in single-user mode and restore master from your last backup:
net start MSSQLSERVER /m"SQLCMD"
sqlcmd -S . -E -Q "RESTORE DATABASE master FROM DISK = N'B:\Backup\master.bak' WITH REPLACE;"
The instance stops after restoring master. Start it normally, then restore msdb and model if needed.
Caution
A rebuild without a master backup loses logins, linked servers and server configuration. Script logins (
sp_help_revlogin) and keep master/msdb backups before you need them.
Fix D: permissions or service account
- Re-set the service account in SQL Server Configuration Manager (not services.msc). It reapplies folder and registry rights.
- Check the account isn't locked or expired, and has Log on as a service.
Fix E: port or certificate
Get-NetTCPConnection -LocalPort 1433 -State Listen | Select OwningProcess
If another process holds the port, stop it or change SQL Server's port. If the error mentions a certificate (forced encryption with an expired or missing cert), remove the certificate selection in Configuration Manager → Protocols → Certificate, start the service, then install a valid certificate.
Step 3: after it starts
SELECT name, state_desc FROM sys.databases;: check user databases came online.- Run a backup of master, msdb and critical user databases if the last good one is old.
- Record the cause and fix in the server's runbook.
Prevent it next time
- Back up master and msdb daily; keep the startup parameters documented.
- Startup script for tempdb folders on ephemeral disks.
- Change service accounts only in Configuration Manager.
- Monitor certificate expiry when encryption is forced.