4060
MediumDatabase Engine

Cannot Open Database — the database requested by the login cannot be opened

What 4060 Means

The 4060 error on the SQL Server engine-errors indicates cannot open database — the database requested by the login cannot be opened. This typically occurs due to the database name in the connection string is incorrect.

Error 4060 occurs when a connection is successfully authenticated (unlike 18456) but the server cannot switch the session to the requested database.

Technical Background

Unlike error 18456 which is a general identity failure, error 4060 indicates that the server knows who you are, but it cannot place your session into the database you requested. This is often because the database is 'offline', in 'single-user' mode, or the user lacks 'CONNECT' permission.

If no database is specified in the connection string, SQL Server tries to connect you to your 'default database'. If that default database has been deleted or taken offline, the login will fail with this error.

Common Causes

  • The database name in the connection string is incorrect
  • The database is offline or in emergency mode
  • The user does not have permission to access the specific database

Typical Scenarios

  • Connecting to a restored database before permissions have been remapped
  • A database being renamed while applications are still using the old name

What to Know

Checking that the target database is online and accessible is the primary step. In cases of invalid default databases, administrative reconfiguration of the login is required to restore access.

Frequently Asked Questions

Common questions about SQL Server 4060 error

18456 is an authentication failure (identity), while 4060 is an authorization or availability failure (accessing a specific database).