pgref.dev/sqlite/errors/SQLITE_IOERR_WRITE
SQLITE_IOERR_WRITEFATALTier 3 — Handle with care⚠️ MEDIUM confidence

I/O error during file write

Category: I/O ErrorVersions: 3.0+

🔴 Production Risk Error

Critical — database may be corrupt after a partial write.

What this means

SQLITE_IOERR_WRITE (778) is returned when the OS reports an error during a write to the database file. The write may have been partial, leaving the database in an inconsistent state.

Why it happens

  1. 1Disk full (ENOSPC).
  2. 2Hardware failure during write.
  3. 3Network filesystem disconnect.
  4. 4Read-only filesystem.

How to reproduce

Any write transaction when the OS write() syscall fails.

trigger — this will ERROR
# Check disk space:
# df -h /path/to/database
sqlite3.DatabaseError: disk I/O error

Fix 1

Why this works

Free disk space: df -h to identify the full filesystem.

Fix 2

Why this works

Check for hardware errors: dmesg | tail -50

Fix 3

Why this works

Use WAL mode to reduce write amplification.

Fix 4

Why this works

Restore from backup after addressing the root cause.

What not to do

Why it's wrong:

Sources

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

🔧 Source ref: sqlite3.h — SQLITE_IOERR_WRITE = 778

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 →