Troubleshooting Guide: Error 5515 – Cannot Open FILESTREAM Container Directory
Why This Error Happens
Error 5515 occurs when the SQL Server service account lacks the necessary NTFS permissions to access the FILESTREAM container directory, or when the directory itself has been moved, deleted, or corrupted outside of SQL Server’s control. This can also happen if the FILESTREAM feature was disabled at the instance level after the database was created, or if the underlying volume has disk-level errors preventing the operating system from returning a valid handle to the folder. Additionally, antivirus software or Windows Server 2025’s enhanced file-locking policies may intermittently block access to the container.
Step-by-Step Resolution Guide
Step 1: Verify FILESTREAM is Enabled at the Instance Level
- Open SQL Server Configuration Manager on Windows Server 2025/Windows 11.
- Navigate to SQL Server Services > right-click your instance > Properties > FILESTREAM tab.
- Ensure “Enable FILESTREAM for Transact-SQL access” is checked.
- Run the following query to confirm at the engine level:
EXEC sp_configure filestream_access_level, 2;
RECONFIGURE;
Step 2: Check and Repair NTFS Permissions on the Container Directory
- Locate the physical path of the FILESTREAM container (e.g.,
D:\SQLData\FileStreamContainer). - Right-click the folder > Properties > Security tab.
- Ensure the SQL Server service account (e.g.,
NT Service\MSSQLSERVER) has Full Control. - Apply permissions via command line if GUI access is restricted:
icacls "D:\SQLData\FileStreamContainer" /grant "NT SERVICE\MSSQLSERVER":(OI)(CI)F /T
Step 3: Validate the Directory Path and Volume Integrity
- Confirm the directory has not been manually renamed, deleted, or relocated.
- Run
chkdsk D: /fto scan for and repair file system errors on the hosting volume. - If the directory is missing entirely, restore it from a recent backup rather than recreating an empty folder, as SQL Server requires specific internal GUID-based subfolder structures.
Step 4: Exclude the Directory from Antivirus/Windows Defender Scanning
- Open Windows Security > Virus & threat protection > Manage settings > Exclusions.
- Add the FILESTREAM container’s root path and the
MSSQLdata directory as exclusions. - Restart the SQL Server service to clear any residual file locks:
Restart-Service -Name "MSSQLSERVER" -Force
Step 5: Review SQL Server Error Log for OS Status Code Details
- Open the SQL Server error log via SSMS or
Notepad(path typicallyC:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log). - Cross-reference the specific
0x%xstatus code returned with Windows system error codes (e.g.,0x5= Access Denied,0x3= Path Not Found) usingnet helpmsg <code>in Command Prompt. - Use this code to pinpoint whether the issue is permissions-based or path-based before proceeding further.
Alternative or Verification Steps
- To verify the fix, run a test query against a table containing a FILESTREAM column (e.g.,
SELECT * FROM dbo.YourTable WHERE FileStreamColumn IS NOT NULL;) and confirm no 5515 error is thrown. - If the error persists, use
sp_helpfileto check the logical path registered in SQL Server against the physical path on disk; a mismatch here often requires detaching and reattaching the database withALTER DATABASE... MODIFY FILEto correct the stored path.