pgref.dev/sqlite/errors/SQLITE_IOERR_CLOSE
SQLITE_IOERR_CLOSEWARNINGTier 2 — Caution⚠️ MEDIUM confidence

I/O error closing file descriptor

Category: I/O ErrorVersions: 3.0+

🔴 Production Risk Error

Medium — indicates possible write-back failure; check disk.

What this means

SQLITE_IOERR_CLOSE (4106) is returned when close() on a database-related file descriptor returns an error. On Linux, close() errors are rare but may indicate a write-back failure.

Why it happens

  1. 1OS write-back error on close() (Linux: EIO flushing dirty pages).
  2. 2File descriptor already closed (double-close bug in VFS).

How to reproduce

SQLite connection close when the OS close() syscall fails.

trigger — this will ERROR
# Surfaces when closing database connection
conn.close()  # may raise OperationalError in some drivers
sqlite3.OperationalError: disk I/O error

Fix 1

Why this works

Check disk health — close() errors often indicate a deferred write failure.

Fix 2

Why this works

Ensure no double-close bugs exist in custom VFS implementations.

Sources

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

🔧 Source ref: sqlite3.h — SQLITE_IOERR_CLOSE = 4106

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 →