About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
Error 5133, "Directory lookup for the file failed with the operating system error", means the restore tried to create a database file in a folder that does not work on this server. A backup records the file paths of the server it came from, and a plain RESTORE writes each file back to that original location. The fix is to list the files in the backup and restore with a MOVE clause for each one, pointing at folders that exist on the new server and that the SQL Server service account can write to.
What the error means
Microsoft lists error 5133 in its Database Engine errors, 5,000 to 5,999 reference as severity 16 with the message Directory lookup for the file "%ls" failed with the operating system error %ls. Two related messages appear in the 3,000 to 3,999 list: error 3156, File '%ls' cannot be restored to '%ls'. Use WITH MOVE to identify a valid location for the file., and error 3119, Problems were identified while planning for the RESTORE statement. Previous messages provide details. Error 3156 tells you to use WITH MOVE, and error 3119 says previous messages provide details.
The mechanism is documented on the RESTORE arguments page (page metadata date 2022-05-10). For MOVE, it says "Specify a MOVE statement for every logical file you want to restore from the backup set to a new location. By default, the logical_file_name_in_backup file is restored to its original location." It adds that when you relocate a database or copy it to a different server, MOVE "might be necessary to relocate the database files and to avoid collisions with existing files". The RESTORE page (page metadata date 2023-05-18) gives a version-related example: each version of SQL Server "uses a different default path than earlier versions", so a database created in the default location for an earlier version needs MOVE.
The operating system error at the end of the message tells you why the lookup failed. On Microsoft's Win32 list (MS-ERREF, date not shown), 3 is ERROR_PATH_NOT_FOUND ("The system cannot find the path specified.") and 5 is ERROR_ACCESS_DENIED ("Access is denied."). The 5133 entry itself gives no breakdown of operating system errors.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| Backup from another server, with a drive or folder that does not exist here | Error 5133 with OS error 3, naming a path such as D:\SQLData\... |
RESTORE FILELISTONLY shows PhysicalName values the new server does not have |
MOVE given for the data file but not the log file, or for some files only |
5133 names the one file you did not move | Compare every LogicalName in FILELISTONLY with your MOVE clauses |
| Target folder exists but the service account cannot write there | OS error 5 | Check the SQL Server service account's rights on the folder |
| Different default path between SQL Server versions | A path under an older MSSQLnn.INSTANCE folder |
The PhysicalName contains the source version folder |
| File collision with an existing database | Error about existing files, with 3156 | Look in the target folders for files with the same names |
| Other file types in the backup (FILESTREAM containers) not moved | A Type of S in FILELISTONLY with no matching MOVE |
Count Type values in the file list |
Prove the cause before changing anything
These checks follow the Microsoft pages cited. They have not been run or lab-tested. All are read-only against the backup.
- Read the header to confirm the backup is the one you expect. RESTORE HEADERONLY (page metadata date 2023-05-10) returns
DatabaseName,ServerName,BackupFinishDate,RecoveryModeland other columns. It requiresCREATE DATABASEpermission.
RESTORE HEADERONLY
FROM DISK = N'\\FS01\SQLBackups\Sales_full.bak';
- List the files the backup contains. RESTORE FILELISTONLY (page metadata date 2018-03-30) returns one row per file with
LogicalName,PhysicalName,TypeandFileGroupName.TypeisDfor a data file,Lfor a log file,Ffor a full-text catalog, andSfor a FILESTREAM, FileTable or In-Memory OLTP container.
RESTORE FILELISTONLY
FROM DISK = N'\\FS01\SQLBackups\Sales_full.bak';
You will use LogicalName in MOVE, and PhysicalName shows the old paths. Check whether those paths exist on the target. If FILELISTONLY returns several rows of type D or L, each needs its own MOVE.
-
Check that the target folder exists and that the SQL Server service account can write to it. The service accounts page (page metadata date 2025-10-14) lists the folders Setup grants to the Database Engine service, including Full control on
Instid\MSSQL\dataandInstid\MSSQL\backup. A folder outside those is not covered by Setup, so grant access yourself. The page does not discuss restore targets. Setup also cannot provision access to a network share used for databases. -
Check the target before restoring. The arguments page says
MOVE"might be necessary to relocate the database files and to avoid collisions with existing files", so look in each target folder for files that already have the names you plan to use, and check free space against the size of the database.
Fix
Restore with MOVE for every file. The shape below follows Microsoft's "Restore a database and move files" example on the RESTORE page. Replace the logical names with the values from step 2, and the paths with folders that exist and are writable on the new server.
RESTORE DATABASE Sales
FROM DISK = N'\\FS01\SQLBackups\Sales_full.bak'
WITH MOVE 'Sales_Data' TO N'E:\SQLData\Sales.mdf',
MOVE 'Sales_Log' TO N'F:\SQLLogs\Sales_log.ldf',
RECOVERY;
RECOVERY is the default, and it ends the restore, so no more log or differential backups can be applied. The RESTORE page example uses NORECOVERY followed by RESTORE LOG ... WITH RECOVERY when logs follow. If you will apply more backups, use NORECOVERY on every step but the last, and then finish with RESTORE DATABASE Sales WITH RECOVERY.
Create the folders first. If the files must go to a path that does not exist yet, create it and set permissions for the service account before running RESTORE. Do this before any retry. Repeating the restore with the same unfixed paths wastes time on a large backup.
Do not add REPLACE to get past path or collision errors. REPLACE "also allows RESTORE to overwrite an existing file that cannot be verified as belonging to the database being restored", and deletes an existing database of the same name. If a file collision is the cause, use MOVE to a different filename instead. Check what the existing files belong to before overwriting anything.
Other file types. A Type of S in the file list is a FILESTREAM, FileTable or In-Memory OLTP container. Move each one as a logical file in the same way, then follow your FILESTREAM restore procedure. The RESTORE page says the full-text data is restored with the database file restore, and the F catalog type applies to catalogs imported from SQL Server 2005. Move whatever FILELISTONLY actually returns.
Example (illustrative). A backup of Sales from SQL01 is restored on SQL02. FILELISTONLY shows Sales_Data at D:\SQLData\Sales.mdf and Sales_Log at L:\SQLLogs\Sales_log.ldf, but SQL02 has no D: or L: drive. The first RESTORE fails with error 5133 naming the D: path and OS error 3. The administrator creates E:\SQLData and F:\SQLLogs, grants the SQL Server service account write access, and restores with two MOVE clauses.
Confirm the fix
sys.databasesshowsstate_descONLINEfor the restored database. The database states page (page metadata date 2025-10-20) definesRESTORINGas unavailable andONLINEas available.- The files sit in the folders you chose. Check the database's file list in your management tool.
- The
msdbrestorehistory table (page metadata date 2017-03-03) has a row with your destination database name,restore_typeD andrecovery1. - Run a business check, not only a technical one. Confirm row counts or a known report against the source, and have the application owner log in. Orphaned users and missing logins are a separate follow-up on a new server.
What to watch afterwards
- Record the target folder layout in your restore runbook, so the next restore does not rediscover it.
- Alert if the data or log volume falls below a free-space threshold. A restore needs space for the whole database.
- If you restore to another server routinely, keep a tested
RESTORE FILELISTONLYplusMOVEscript for each database. - A recurring 5133 on a server you did not change suggests a drive letter changed. Check the volume layout.
Read next
Related articles you may want next.
- TroubleshootingThe Database Restored, but the Application Cannot Log InTrace SQL logins, database users and SID mappings after a restore, and validate application access without broadening application privileges.Read article
- Backup & RecoveryWhy a SQL Server restore takes longer than the backup: file zeroing, virtual log files and recoveryUnderstand file initialisation, virtual log files, log replay and target performance when measuring SQL Server restore time.Read article
- Backup & RecoveryFILESTREAM and FileTable databases: backing up the files that live outside the MDFWhere SQL Server FILESTREAM and FileTable data lives, how native backup and restore include it, partial restore limits, and read-only checks to find it.Read article
Risks and limits
- These commands have not been run or lab-tested. They follow the syntax shapes in Microsoft's documentation.
- Microsoft does not tie 5133, 3156 and 3119 together or give a 5133-specific troubleshooting article. The cause analysis here follows the
MOVEdocumentation. - Full-text catalog (
F) and FILESTREAM (S) restores can have extra steps that this article does not cover. - The service accounts page lists default folder rights, not rules for restore targets, so check the rights on your own target folders.
Sources
- Database Engine events and errors, 5,000 to 5,999 — Microsoft Learn, date not shown, accessed 16 November 2026
- Database Engine events and errors, 3,000 to 3,999 — Microsoft Learn, date not shown, accessed 16 November 2026
- RESTORE (Transact-SQL) — Microsoft Learn, page metadata date 2023-05-18, accessed 16 November 2026
- RESTORE Arguments (Transact-SQL) — Microsoft Learn, page metadata date 2022-05-10, accessed 16 November 2026
- RESTORE FILELISTONLY (Transact-SQL) — Microsoft Learn, page metadata date 2018-03-30, accessed 16 November 2026
- RESTORE HEADERONLY (Transact-SQL) — Microsoft Learn, page metadata date 2023-05-10, accessed 16 November 2026
- Configure Windows Service Accounts and Permissions — Microsoft Learn, page metadata date 2025-10-14, accessed 16 November 2026
- Database States — Microsoft Learn, page metadata date 2025-10-20, accessed 16 November 2026
- restorehistory (Transact-SQL) — Microsoft Learn, page metadata date 2017-03-03, accessed 16 November 2026
- MS-ERREF: Win32 error codes — Microsoft Learn (Open Specifications), date not shown, accessed 16 November 2026
This article was originally published on .