SQL Server Error 4060: Cannot open database requested by the login. The login failed
The login authenticated, but the database named in the connection string doesn't exist or the login can't access it.
Cannot open database requested by the login. The login failed.Cannot open database "X" requested by the loginLogin failed for user. Cannot open databaseSqlException 4060 Meaning
Check Initial Catalog spelling, that the database is online, and that the login is mapped to a user in that database (CREATE USER ... FOR LOGIN). Also check the default database of the login (error 4064).
Common causes
- Database name typo or wrong server
- Database offline, restoring or dropped
- Login has no user in that database
- Default database missing
- Connection to the wrong instance
⚡ Quick fix
- Verify the database name and instance
- Map the login:
USE db; CREATE USER app FOR LOGIN app; - Check
sys.databasesstate
Detailed fix by platform
SQL
- sql
SELECT name, state_desc FROM sys.databases; USE MyDb; CREATE USER app FOR LOGIN app; ALTER ROLE db_datareader ADD MEMBER app;
How to diagnose
- Database — Online?
- User mapped — Yes?
- Instance — Correct?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 10054 SQL Server error 10054: An existing connection was forcibly closed by the remote host
- 1105 SQL Server Error 1105: Could not allocate space for object in database because the PRIMARY filegroup is full
- 15281 SQL Server Msg 15281: SQL Server blocked access to procedure 'sys.xp_cmdshell' (component 'xp_cmdshell' turned off)
Most viewed in SQL
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026