Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server Error 1407: Remote Copy of Database Not Found

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server error 1407 means the database file or log file the instance is trying to open cannot be found at the path recorded in the database metadata — the error text usually reads "The remote copy of database is not found" or "The remote copy of database 'X' is not found. Reissue the statement with the correct database name." The fix is to repoint the database to the correct file location, restore the missing file, or drop the database if it is orphaned. Before you change anything, take a backup of the master and msdb databases and note the current file paths so you can roll back.

What You'll Need

  • Membership in the sysadmin fixed server role (or an account with ALTER DATABASE and ALTER ANY DATABASE permissions).
  • SQL Server Management Studio (SSMS) or sqlcmd connected to the affected instance.
  • Windows access to the file system on the server hosting the data and log files, so you can confirm whether the .mdf and .ldf files exist.
  • A current backup of master and msdb, plus a backup of the affected user database if it is still accessible.
  • The correct file paths for the database files — from a backup, from the original CREATE DATABASE script, or from the server's file system.

Step-by-Step

  1. Identify the exact database and file. Run SELECT name, physical_name FROM sys.master_files WHERE database_id = DB_ID('YourDatabase'); to see the paths SQL Server expects. Compare each path with what actually exists on disk. Menu labels and query output can differ slightly by SQL Server version, but the catalog views are stable.
  2. Confirm the file is missing or moved. In File Explorer on the database server, navigate to the folder shown in physical_name. If the .mdf or .ldf is absent, the file was deleted, moved, or the drive letter changed. If the file exists but SQL Server cannot open it, the service account may lack NTFS permissions — check the file's Security tab and grant the SQL Server service account (for example NT SERVICE\MSSQLSERVER) Full Control on the folder.
  3. Take a backup before changes. Run BACKUP DATABASE master TO DISK = 'C:\Backups\master.bak' WITH INIT; and the same for msdb. If the user database is still online, back it up too. This is your rollback point.
  4. If the file was moved, repoint the database. Take the database offline with ALTER DATABASE YourDatabase SET OFFLINE WITH ROLLBACK IMMEDIATE;, then update the path: ALTER DATABASE YourDatabase MODIFY FILE (NAME = LogicalFileName, FILENAME = 'D:\NewPath\YourDatabase.mdf');. Repeat for the log file. Then bring it online with ALTER DATABASE YourDatabase SET ONLINE;. If the database is already in a recovery-pending or suspect state, use ALTER DATABASE YourDatabase SET EMERGENCY; first, then ALTER DATABASE YourDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE;, then run DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS only as a last resort — that option can lose data, so restore from backup first if you can.
  5. If the file was deleted and no backup exists, restore it. Restore the latest full backup with RESTORE DATABASE YourDatabase FROM DISK = 'C:\Backups\YourDatabase.bak' WITH REPLACE, RECOVERY;. WITH REPLACE overwrites the existing database — confirm you have the right backup and that overwriting is acceptable before running it.
  6. If the database is orphaned and not needed, drop it. Use DROP DATABASE YourDatabase; only after confirming the data is not required and you have a backup. Dropping a database permanently deletes its files and metadata.
  7. Verify the fix. Run SELECT name, state_desc FROM sys.databases WHERE name = 'YourDatabase'; — state_desc should read ONLINE. Then run a simple SELECT TOP 1 * FROM YourDatabase.dbo.SomeTable; to confirm the database is readable.

Common Mistakes

  • Changing the FILENAME in ALTER DATABASE without first taking the database offline — SQL Server may reject the change or leave the database in an inconsistent state.
  • Forgetting to update both the .mdf and .ldf paths. Repointing only the data file leaves the log file missing and the error persists.
  • Using WITH REPLACE on a restore without checking which backup you are restoring — this overwrites the live database and any changes made after that backup are lost.
  • Granting permissions to the wrong service account. Named instances use accounts like NT SERVICE\MSSQL$INSTANCENAME, not the default MSSQLSERVER account.
  • Running DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS before trying a restore from backup. That repair option can delete data and should be a last resort.
  • Ignoring the Windows Event Log and SQL Server error log — they often name the exact file and path that failed, which saves guesswork.

Tips

  • Keep a script that records all database file paths (query sys.master_files) so you can compare before and after any storage change.
  • When moving files, use the documented sequence: OFFLINE, MODIFY FILE, move the physical file in Windows, then ONLINE. Doing it in a different order causes exactly this error.
  • Check drive letters after adding or removing disks — a changed drive letter is a common cause of missing files on reboot.
  • Use SQL Server Configuration Manager to confirm which account the SQL Server service runs under before changing NTFS permissions.
  • Test restores on a non-production instance first so you know the backup is valid and the paths work.

Troubleshooting

If the database still will not come online after repointing the files, check the SQL Server error log for the exact file and error. If the error mentions access denied rather than file not found, it is a permissions issue — grant the service account Full Control on the folder and restart the SQL Server service. If the database is marked SUSPECT, do not detach it; restore from backup or run emergency-mode repairs with a backup in hand. If the error appears when connecting from a remote client rather than on the server itself, confirm you are connected to the correct instance and that the database name is spelled correctly — error 1407 can also appear when a client specifies a database that does not exist on that instance. If a restore fails because the file is in use, take the database offline or stop the dependent service, then retry. When in doubt, restore master from backup to recover the original metadata, then reapply your file-path changes.

Frequently Asked Questions

What causes SQL Server error 1407?

The most common cause is that a database file (.mdf or .ldf) has been moved, renamed, or deleted, so the path stored in SQL Server metadata no longer matches the file system. Less often it is an NTFS permission problem or a client connecting to the wrong instance.

Can I fix error 1407 without a backup?

Yes, if the file still exists somewhere on disk — repoint the database to the new path with ALTER DATABASE MODIFY FILE. If the file is truly gone and you have no backup, the data in that database cannot be recovered; you can only drop the orphaned database.

Does error 1407 mean data is lost?

Not necessarily. If the file was moved rather than deleted, repointing restores full access with no data loss. If the file was deleted and you have a backup, restore it. Data is only lost if the file is gone and no backup exists.

Why does the error appear only for some logins?

A login mapped to a default database that is offline or missing will fail with a similar error at connection time. Check the login's default database setting and point it to an existing database, or bring the missing database online.

Can I use DROP DATABASE to clear the error?

Yes, but only if you are certain the data is not needed. DROP DATABASE permanently removes the database and its files. Back up first, and confirm no application depends on it.

Is error 1407 related to remote servers or linked servers?

Despite the word "remote" in the message, error 1407 is almost always a local file-path or metadata problem on the instance you are connected to. Check local paths and permissions first before investigating linked servers.