// SQLite error reference

SQLITE_READONLY_ROLLBACK: hot journal can't be rolled back

The database has a hot journal left by a crash that must be rolled back, but the connection can't write, so the database can't be opened.

Result code
SQLITE_READONLY_ROLLBACK
Name
776
Category
Extended result codes
Error message
attempt to write a readonly database

What it means

SQLITE_READONLY_ROLLBACK (776) means the database file has a hot journal: a -journal file from a transaction that was interrupted by a crash. SQLite has to roll that journal back before anyone can read consistent data, and rolling back needs write access, which this connection doesn't have.

Common causes

  • A program crashed mid-transaction, and the database is now being opened read-only or by a user without write permission.
  • The database and its journal were copied to read-only media.

How to fix it

  1. Open the database once with a user and mode that can write, so SQLite rolls the journal back; after that it can be opened read-only again.

  2. Never delete the -journal file to get around this: it holds the data needed to undo the interrupted transaction, and deleting it can corrupt the database.

Related errors

More extended result codes errors

The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.

// fewer errors, faster fixes

Work on SQLite in SQLly

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