// SQL Server error reference

SQL Server error 9001: The log for database is not available

SQL Server lost access to the database's transaction log, usually because of an I/O failure on the log file, and took the database offline.

Error number
9001
Severity
21
Category
Corruption and I/O
Error message
The log for database '%.*ls' is not available. Check the operating system error log for related error messages. Resolve any errors and restart the database.

What it means

Every change goes through the transaction log, so when SQL Server can't read or write the log it can't safely continue. Error 9001 (severity 21) takes the database out of service. The operating system error that caused it is in the error log just before 9001.

Common causes

  • The disk or volume holding the log file failed or became unavailable.
  • Storage errors while writing the log.
  • In some cases, an auto-closed database whose log can't be reopened.

How to fix it

  1. Check the SQL Server error log and the operating system event log for the I/O error that preceded 9001, and fix the storage.

  2. Once the storage is healthy, try to bring the database back online.

    ALTER DATABASE SalesDb SET OFFLINE WITH ROLLBACK IMMEDIATE;
    ALTER DATABASE SalesDb SET ONLINE;
  3. Run DBCC CHECKDB afterwards. If the log is damaged, restore from backup.

  4. If AUTO_CLOSE is on, turn it off.

    ALTER DATABASE SalesDb SET AUTO_CLOSE OFF;

Related errors

More corruption and i/o errors

The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.

// fewer errors, faster fixes

Work on SQL Server in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.