pgref.dev/sqlite/errors/SQLITE_IOERR_READ
SQLITE_IOERR_READFATALTier 3 — Handle with care⚠️ MEDIUM confidence

I/O error during file read

Category: I/O ErrorVersions: 3.0+

🔴 Production Risk Error

Critical — likely hardware failure; restore from backup.

What this means

SQLITE_IOERR_READ (266) is returned when the OS reports an error while reading from the database file. The data read may be incomplete or corrupt.

Why it happens

  1. 1Hardware failure (failing HDD/SSD).
  2. 2NFS or network filesystem disconnect mid-read.
  3. 3Filesystem corruption.
  4. 4Disk removed or unmounted while database was open.

How to reproduce

sqlite3_step() or any read operation when the OS read() syscall fails.

trigger — this will ERROR
# SQLITE_IOERR_READ typically surfaces as:
# sqlite3.DatabaseError: disk I/O error
sqlite3.DatabaseError: disk I/O error

Fix 1

Why this works

Check filesystem health: dmesg | grep -i error

Fix 2

Why this works

Run SMART test on the disk: smartctl -a /dev/sda

Fix 3

Why this works

Restore the database from backup.

Fix 4

Why this works

Use WAL mode on local SSDs to reduce I/O failures.

What not to do

Why it's wrong:

Sources

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

🔧 Source ref: sqlite3.h — SQLITE_IOERR_READ = 266

📖 Further reading: SQLite I/O error codes

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 →