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

Troubleshooting Guide: SQL Server Error 1813 — “Could not open new database. CREATE DATABASE is aborted.”

Why This Error Happens

Error 1813 typically occurs when SQL Server cannot create or access the physical database files during a CREATE DATABASE or database restore operation. The most common root causes are insufficient NTFS permissions for the SQL Server service account on the target data/log directory, a pre-existing file with the same name already locked by another process, or the destination disk/volume running out of space. In some cases, a prior failed database creation leaves orphaned files that block the new operation, or the model database (used as a template for new databases) is itself corrupted or inaccessible.

Step-by-Step Resolution Guide

Step 1: Verify Disk Space and File Path Availability

  • Check the target drive (e.g., D:\SQLData\ or E:\SQLLogs\) has sufficient free space using File Explorer or Get-PSDrive in PowerShell.
  • Confirm no orphaned .mdf, .ndf, or .ldf files already exist in the target path with the same database name.
  • Delete or rename any leftover files from a previously failed creation attempt (ensure they aren’t in use first).

Step 2: Validate NTFS Permissions for the SQL Server Service Account

  • Open File Explorer, navigate to the data/log directory (e.g., C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\DATA).
  • Right-click the folder → Properties → Security tab, and confirm the SQL Server service account (e.g., NT Service\MSSQLSERVER or a custom domain account) has Full Control.
  • If missing, click Edit → Add, type the service account name, grant Full Control, and click Apply.
  • Restart the SQL Server service via services.msc or run:
Restart-Service -Name 'MSSQLSERVER' -Force

Step 3: Check the Integrity of the Model Database

  • Run DBCC CHECKDB (model) in SQL Server Management Studio (SSMS) to confirm the model database isn’t corrupted.
  • If corruption is found, restore the model.mdf and modellog.ldf files from a known good backup, or rebuild system databases using:
setup.exe /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=BUILTIN\Administrators

Step 4: Review SQL Server Error Logs for Underlying OS Errors

  • Open SSMS → Management → SQL Server Logs, and look for OS-level error codes (e.g., Error 5 “Access Denied” or Error 112 “Not enough disk space”) accompanying the 1813 message.
  • Cross-reference with Windows Event Viewer (eventvwr.msc) under Windows Logs > Application for any related disk or security warnings.

Alternative or Verification Steps

  • After applying fixes, re-run the original CREATE DATABASE TestDB ON (NAME = TestDB, FILENAME = 'D:\SQLData\TestDB.mdf') command and confirm it completes without error.
  • As an alternative, try creating the database on a different drive/volume (e.g., switch from D:\ to C:\) to isolate whether the issue is specific to disk permissions or storage hardware.