4060 SQL Origin: Data OSI layer 7 · Application Last updated 18 Nov 2026

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.

Exact message you may see 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
Seen on: SQL Server SQL

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

  1. Verify the database name and instance
  2. Map the login: USE db; CREATE USER app FOR LOGIN app;
  3. Check sys.databases state

Detailed fix by platform

SQL

  1. 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

  1. Database — Online?
  2. User mapped — Yes?
  3. 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:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

10054 — SQL Server error 10054: An existing connection was forcibly closed by the remote host (SQL)100541105 — SQL Server Error 1105: Could not allocate space for object in database because the PRIMARY filegroup is full (SQL)110515281 — SQL Server Msg 15281: SQL Server blocked access to procedure 'sys.xp_cmdshell' (component 'xp_cmdshell' turned off) (SQL)1528118452 — SQL Server Error 18452: Login failed. The login is from an untrusted domain and cannot be used with Windows authentication (SQL)1845218456 — SQL Server: Login failed for user 'x'. (Error 18456) (SQL)18456209 — SQL Server Msg 209: Ambiguous column name (SQL)209229 — SQL Server Msg 229: The SELECT permission was denied on the object (SQL)2292714 — SQL Server Msg 2714: There is already an object named 'X' in the database (SQL)27144060

Explore the map of this error Full error map →

🧠 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.