How to fix Error 5133 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 5133

Why This Error Happens

Error 5133 occurs when SQL Server 2025 cannot resolve the directory path specified for a database file during creation, attachment, or restore operations. This is typically caused by the target folder not existing on disk, the SQL Server service account lacking NTFS permissions on the path, or the path containing an invalid drive letter/UNC reference. In some cases, this also surfaces when antivirus or endpoint protection software is locking the target directory before SQL Server can validate it.

Step-by-Step Resolution Guide

Step 1: Verify the Target Directory Exists

  • Open File Explorer or Command Prompt on the Windows Server 2025 / Windows 11 host and confirm the exact path referenced in the error (e.g., D:\SQLData\MSSQL17.MSSQLSERVER\MSSQL\DATA\).
  • If the folder is missing, create it manually using mkdir "D:\SQLData\MSSQL17.MSSQLSERVER\MSSQL\DATA".
  • Double-check for typos in the CREATE DATABASE, ATTACH, or RESTORE statement, especially trailing slashes or incorrect drive letters.

Step 2: Validate SQL Server Service Account Permissions

  • Open Services.msc and note the account running “SQL Server (MSSQLSERVER)” or your named instance.
  • Right-click the target folder (e.g., D:\SQLData\) → Properties → Security tab.
  • Grant Full Control to the SQL Server service account (typically NT Service\MSSQLSERVER or a domain service account).
  • Apply permissions recursively using: icacls "D:\SQLData" /grant "NT SERVICE\MSSQLSERVER":(OI)(CI)F /T

Step 3: Check for Disk, Mount Point, or UNC Path Issues

  • If using a UNC path or mapped network drive, confirm SQL Server supports it (local service accounts cannot resolve mapped drives reliably).
  • For UNC paths, ensure the SQL Server service account has been granted share-level and NTFS permissions, and that the path is reachable via Test-Path \\server\share\folder in PowerShell.
  • If using Storage Spaces or a mounted volume, confirm the volume is online via Disk Management (diskmgmt.msc) and not in a “Reserved” or “Offline” state.

Step 4: Temporarily Disable Antivirus/EDR Scanning on SQL Paths

  • Add exclusions in Windows Defender or third-party AV for SQL Server data/log directories (.mdf, .ldf, .ndf extensions and folder paths).
  • Restart the SQL Server service after applying exclusions: Restart-Service MSSQLSERVER.

Step 5: Review SQL Server Error Log for OS-Level Detail

  • Open the SQL Server Error Log via SSMS (Management → SQL Server Logs) or directly from C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG.
  • Match the embedded Windows OS error code (e.g., “Access is denied” or “The system cannot find the path specified”) to pinpoint whether this is a permissions or path-existence issue.

Alternative or Verification Steps

  • Re-run the original CREATE DATABASE, ATTACH DATABASE, or RESTORE DATABASE command and confirm it completes without Error 5133.
  • As an alternative, use SSMS’s “Browse” button in the file path dialog (instead of typing the path manually) to let SQL Server validate directory access interactively before executing the script.