pgref.dev/sqlite/errors/SQLITE_READONLY_ROLLBACK
SQLITE_READONLY_ROLLBACKWARNINGTier 2 — Caution⚠️ MEDIUM confidence

Read-only: rollback journal prevents read

Category: Read-OnlyVersions: 3.7.8+

🔴 Production Risk Error

High — database is inaccessible until journal is processed.

What this means

SQLITE_READONLY_ROLLBACK (776) is returned when a read-only database has a hot journal that needs to be rolled back, but the connection cannot write the journal file to perform the rollback.

Why it happens

  1. 1Crash left a hot journal (-journal file) alongside the read-only database.
  2. 2Read-only connection cannot roll back the journal.

How to reproduce

Read-only access to a database with an orphaned rollback journal.

trigger — this will ERROR
# A -journal file exists but db is opened read-only
# SQLITE_READONLY_ROLLBACK prevents reads until journal is cleared
sqlite3.OperationalError: attempt to write a readonly database

Fix 1

Why this works

Open the database read-write briefly so SQLite can roll back the hot journal, then close it.

Fix 2

Why this works

Manually delete the -journal file if certain no write transaction was in progress.

What not to do

Why it's wrong:

Sources

📚 Official docs: https://www.sqlite.org/rescode.html#readonly_rollback

🔧 Source ref: sqlite3.h — SQLITE_READONLY_ROLLBACK = 776

📖 Further reading: SQLite journaling modes

Confidence assessment

⚠️ MEDIUM confidence

Stable.

See also

⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →