SQL Server engine errors

Cannot Open Database

4060
MediumDatabase Engine

Reviewed for reference consistency: August 11, 2026

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 misspelled, or it names a database that was renamed or dropped.

Error 4060 means SQL Server cannot open the database your login requested: credentials were accepted, but the database itself is unavailable. The database may be offline or in a restricted state such as single-user or emergency mode, the name in the connection string may be wrong, or the login may lack a user mapping with CONNECT access inside it. Severity 11 puts 4060 in the class Microsoft describes as user-correctable errors, so the fix usually sits in the connection string, the login's default database, or the database state.

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.

  1. 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';
  2. 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';
  3. 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];
  4. 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 fails; error 4064 is the message dedicated to that case.

The official message text is 'Cannot open database "%.*ls" requested by the login. The login failed.', raised at severity 11 and not written to the event log. Severity 11 is the band Microsoft assigns when the object or entity named in the request does not exist or cannot be reached.

Comparing 4060 with 4064 tells you which database the server was trying to open: 4060 names an explicitly requested database, while 4064 points at the login's default.

Common Causes

  • The database name in the connection string is misspelled, or it names a database that was renamed or dropped
  • The target database is offline, in emergency mode, or otherwise in a state that refuses new sessions
  • The login has no user mapping with CONNECT permission inside the requested database
  • The login's default database no longer exists or is unavailable, so the initial database open fails

Typical Scenarios

  • An application's connection string still names a database that was renamed or dropped, so every new connection fails with 4060 while the server itself is healthy
  • A database restored from another instance leaves the login without a matching user inside the restored copy, so the database open fails on first connect
  • A login whose default database was dropped or taken offline fails at connect time even though the connection string names no database, because the server attempts the default first
  • A database set to single-user for maintenance rejects every session except the single permitted one, so applications receive 4060 until the mode is lifted

What to Know

Checking that the target database is online and accessible is the primary step. If the database state is healthy, work through the connection string, the login's user mapping, and the login's default database; fixing a broken default database means reconfiguring the login itself.

Frequently Asked Questions

Common questions about SQL Server 4060 error

18456 fails at authentication: the server does not accept the credentials, and no database is named in the message. 4060 happens one stage later — the credentials are accepted, and the failure is opening the database the connection requested.

4060 names the database it could not open: 'Cannot open database ... requested by the login. The login failed.' 4064 is the message dedicated to the default-database case: 'Cannot open user default database. Login failed.' Both end with 'Login failed'; comparing the two tells you whether an explicitly named database or the login's default was the problem.

Not necessarily. 4060 reports which database could not be opened, which means authentication already succeeded. The phrase 'The login failed' refers to the failed attempt to establish the session inside that database, not to a wrong password.

Usually not. The error carries severity 11, a range Microsoft describes as errors that can be corrected by the user. The corrections are database-level settings: the connection string, the login's default database, the database state, or the login's user mapping.

Related Errors From Other Categories

Similar error codes documented across different platforms and systems