Fix SQL Server Error 3156 (Cannot Restore File) in 4 Ways

8 min read

SQL Server error 3156 says a file cannot be restored to the path that the backup names. Error 3156 stops the restore before SQL Server creates the database.

This guide explains how to find the cause and gives four fixes in the order that costs you the least time.

Quick SummarySQL Server error 3156 means a restore cannot place a file. Your backup file is not the problem. List the logical file names with RESTORE FILELISTONLY. Add a MOVE clause for every file that needs a new path. Give the SQL Server service account access to the folder. Check the state number for the memory optimized folder case. Verify the backup with RESTORE VERIFYONLY.

What Does SQL Server Error 3156 Say About the File?

According to the Microsoft page for error 3156, error 3156 names the files that SQL Server could not restore because of a problem with the location. The message gives the logical name first and the physical path second.

File 'OrdersDB' cannot be restored to 'D:\SQLData\OrdersDB.mdf'. Use WITH MOVE to identify a valid location for the file.

Microsoft lists three causes for the location problem.

  • No access. The SQL Server service account has no right to the Windows folder.
  • Wrong path. The path has a typing error or the folder does not exist on this server.
  • File in use. The file name belongs to a file that SQL Server cannot overwrite.

Do You Know?A backup stores the file paths of the server that made it. A restore on another server or on a new volume fails with error 3156 when those folders do not exist. Follow fix SQL Server error 3154 when the message says the backup set belongs to a different database.

How to Find Which Location Caused Error 3156?

Check the files in the backup and the default paths of the instance before you restore again. The first query lists the logical names and the paths stored in the backup.

RESTORE FILELISTONLY FROM DISK = N'D:\Backup\OrdersDB.bak';

Expected output has one row for every data file and the log file. Copy the LogicalName column because the MOVE clause must match it. The next query shows where the instance stores new files by default.

SELECT SERVERPROPERTY('InstanceDefaultDataPath') AS DataPath,
 SERVERPROPERTY('InstanceDefaultLogPath') AS LogPath;

Check the messages next to 3156 for an operating system error. Error 3 means the path was not found and error 5 means access was denied. The state number narrows the cause as well. Microsoft documents State 6 for a backup that has a memory optimized filegroup.

What you find Cause Start with
Operating system error 3 or a folder that does not exist on this server Path from the old server Method 1
Operating system error 5 or Access is denied Service account has no folder access Method 2
The file name already exists in the folder File that cannot be overwritten Method 1 with a new file name
State 6 and the backup has a memory optimized filegroup Folder name clash for the filegroup Method 3
Msg 5184 says the file cannot be used for a clustered server Volume is not a resource of the SQL Server cluster role Method 4

How to Fix SQL Server Error 3156?

Every example uses the backup OrdersDB.bak. Replace the names and the paths with your own values.

Method 1: Move the Files With WITH MOVE

Use this method when the paths in the backup do not exist or when a file name is taken. Microsoft states that the logical names in the MOVE clause must match the names in the backup. Add one MOVE clause for every file that needs a new path.

RESTORE DATABASE OrdersDB_Copy
FROM DISK = N'D:\Backup\OrdersDB.bak'
WITH MOVE N'OrdersDB' TO N'E:\SQLData\OrdersDB_Copy.mdf',
 MOVE N'OrdersDB_log' TO N'F:\SQLLog\OrdersDB_Copy_log.ldf',
 RECOVERY;

Add a MOVE clause for every NDF file in the FILELISTONLY output. A file without a MOVE clause goes to the path stored in the backup. Use a new database name and new file names when you restore next to the original database. Follow restore database with NORECOVERY when you restore a full backup and log backups in sequence.

Method 2: Give the SQL Server Service Account Access to the Folder

Use this method when the messages show operating system error 5. The database engine creates the files so the service account needs modify rights on the folder. Open SQL Server Configuration Manager to see which account the service uses.

icacls "E:\SQLData" /grant "NT Service\MSSQLSERVER:(OI)(CI)M"

Use NT Service\MSSQL$INSTANCENAME for a named instance. The (OI)(CI)M part applies the modify right to the folder and to everything created inside it. Restore again after the grant.

Method 3: Give the Memory Optimized Filegroup a Different Folder

Use this method when the error shows State 6. SQL Server creates a folder for a memory optimized filegroup during the restore. A folder with the same name in the same path, used by SQL Server or by another process, stops the restore. Microsoft documents this case and the workaround on its error 3156 troubleshooting page.

RESTORE FILELISTONLY FROM DISK = N'D:\Backup\OrdersDB.bak';
RESTORE DATABASE OrdersDB_Copy
FROM DISK = N'D:\Backup\OrdersDB.bak'
WITH MOVE N'OrdersDB' TO N'E:\SQLData\OrdersDB_Copy.mdf',
 MOVE N'OrdersDB_log' TO N'F:\SQLLog\OrdersDB_Copy_log.ldf',
 MOVE N'OrdersDB_mod' TO N'E:\SQLData\OrdersDB_Copy_mod',
 RECOVERY;

The row with Type S in the FILELISTONLY output is the memory optimized container. Give it a folder name that does not exist in the destination path. In-Memory OLTP starts with SQL Server 2014 so this case does not apply to older backups.

Method 4: Use a Volume That Belongs to the Cluster Role

Use this method when Msg 5184 appears next to error 3156 on a failover cluster instance. SQL Server can use only a volume that is a resource of its own cluster role. Place the files on a shared volume of that role and restore again with MOVE.

SELECT DISTINCT volume_mount_point
FROM sys.master_files AS f
CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.file_id);

The query lists the volumes that the instance uses now. Select a path on one of them. The reason for Msg 5184 comes from practitioner reports and not from a Microsoft page.

Heads UpError 3156 does not mean the backup file is damaged. Execute RESTORE VERIFYONLY on the backup when you want proof before you search for another cause.

Common Questions on Error 3156

Does Error 3156 Mean the Backup File Is Damaged?

No. Error 3156 points to the location of a file in the restore and not to the backup. Verify the backup with RESTORE VERIFYONLY when you want proof.

Where Do You Find the Logical File Names?

Execute RESTORE FILELISTONLY on the backup. The LogicalName column lists the names. Microsoft states that the names in your MOVE clauses must match them.

Do You Need a MOVE Clause for Every File?

Yes. Add one MOVE clause for every file that needs a new path, including every NDF file and the log file. A file without a MOVE clause goes to the path stored in the backup.

Which Account Needs Folder Access?

The SQL Server service account needs modify rights on the folder because the database engine creates the files. Your own login does not matter for this step.

Why Does Error 3156 Show State 6?

State 6 points to a memory optimized filegroup. SQL Server creates a folder for it and a folder with the same name in the same path stops the restore. Use MOVE to give it a different name or path.

How to Avoid Error 3156 on the Next Restore?

List the file layout with RESTORE FILELISTONLY before every restore on a new server. Save the MOVE clauses in a script so the next restore needs no editing.

Set the default data and log paths of the instance to volumes that exist on every server in your plan. A matching layout removes the need for MOVE in most restores.

Who, How and WhyAndrew Jackson, Technical Content Specialist, wrote this guide. The error text, the three causes and the user actions follow the Microsoft Learn pages for error 3156 linked above. The T-SQL and the icacls command were checked for syntax against Microsoft documentation and were not executed on a live server. The clustered server case with Msg 5184 comes from practitioner reports and was not confirmed on a Microsoft page. The guide exists because restore errors on a new server need a clear way to match the message to the location problem.

Key Takeaways

  • SQL Server error 3156 means a restore cannot place a file at a location.
  • RESTORE FILELISTONLY lists the logical names that the MOVE clause must match.
  • Add one MOVE clause for every file that needs a new path.
  • The SQL Server service account needs modify rights on the destination folder.
  • State 6 points to a memory optimized filegroup folder that already exists.
  • Error 3156 does not mean the backup file is damaged.