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

How to fix it

  1. Confirm the database actually exists and is ONLINE: SELECT name, state_desc FROM sys.databases.
  2. Check the login's default database and permissions: SELECT name, default_database_name FROM sys.server_principals WHERE name = 'login'.
  3. Grant access explicitly if missing: USE [DBName]; CREATE USER [login] FOR LOGIN [login];
  4. 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.
  5. 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 →

Related