SQL Server engine errors
SQL Server 4060 Cannot Open Database
Reviewed for reference consistency: April 11, 2026
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.
How to fix 4060
General informational guidance, not professional advice. Commands can affect your system or data — back up first and proceed at your own risk. FixerCode is an independent reference, not affiliated with any vendor mentioned.
Confirm the database is online
4060 means authentication succeeded but the database could not be opened. Check its state before anything else.
SELECT name, state_desc FROM sys.databases WHERE name = 'YourDb';Verify the login is mapped to a user
The login needs a database user with CONNECT permission inside the target database.
USE YourDb; SELECT name FROM sys.database_principals WHERE name = 'youruser';Fix an invalid default database
If the login's default database is offline or deleted, connections fail before reaching a valid one. Point the default at master.
High-impact command - back up first and proceed carefully.
ALTER LOGIN [youruser] WITH DEFAULT_DATABASE = [master];Correct the connection string
Make sure the Database or Initial Catalog value names a database the login is actually allowed to open.
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).