DBAtlas · Database operations atlas

4060: Cannot open database requested by the login. The login failed

SQL Server

What does it mean?

Authentication may succeed, but the connection is rejected because the requested database cannot be opened. Usually seen together with 18456.

Why does it happen?

The database does not exist, is OFFLINE/SINGLE_USER/RESTORING/SUSPECT, the login has no user mapping in that database, or the default database in the connection string is inaccessible.

How to fix it

Verify that the database exists and is ONLINE: SELECT name, state_desc FROM sys.databases. Create a user for the login in the database and grant permissions. Check the Initial Catalog/Database value in the connection string. If the database is RESTORING/SUSPECT, follow the repair/restore steps.

Open in DBAtlas →

More from this engine