SQL Server Error 4060 — Cannot open database requested by the login
Cannot open database "DBName" requested by the login. The login failed.
The login connected to the SQL Server instance fine, but the specific database it tried to use either doesn't exist, isn't accessible, or the login isn't permitted to use it.
Common causes
- The database name is misspelled, or was renamed/dropped since the connection string was written
- The login's default database was dropped or detached, and no database was explicitly specified either
- The login has no CONNECT permission on that specific database (exists, but access was never granted)
- The database is offline, in RESTORING, or otherwise not in a queryable state
- A contained database authentication mismatch (login exists at the server level but the app expects contained auth, or vice versa)
How to fix it
- Confirm the database actually exists and is ONLINE: SELECT name, state_desc FROM sys.databases.
- Check the login's default database and permissions: SELECT name, default_database_name FROM sys.server_principals WHERE name = 'login'.
- Grant access explicitly if missing: USE [DBName]; CREATE USER [login] FOR LOGIN [login];
- If the database is offline/restoring, that state needs to be resolved first (finish the restore, bring it online) before any login can use it.
- Double-check the exact database name in the connection string against sys.databases — case and typos are the most common cause.
Paste your connection string context and the exact error here for a fix specific to your setup.
Try error explainer free →