pgref.dev/sqlite/errors/SQLITE_CANTOPEN_SYMLINK
SQLITE_CANTOPEN_SYMLINKERRORTier 2 — Caution⚠️ MEDIUM confidence

Cannot open — symlinks not allowed

Category: File AccessVersions: 3.31.0+

🔴 Production Risk Error

Low — intentional security restriction.

What this means

SQLITE_CANTOPEN_SYMLINK (2062) is returned when SQLITE_OPEN_NOFOLLOW is set and the database path is a symbolic link. This prevents following symlinks for security-sensitive applications.

Why it happens

  1. 1Opening a symlinked database file with the SQLITE_OPEN_NOFOLLOW flag.
  2. 2Security policy forbids following symlinks to database files.

How to reproduce

sqlite3_open_v2() with SQLITE_OPEN_NOFOLLOW flag on a symlinked database.

trigger — this will ERROR
# In C:
# sqlite3_open_v2("mylink.db", &db, SQLITE_OPEN_READONLY | SQLITE_OPEN_NOFOLLOW, NULL);
# → SQLITE_CANTOPEN_SYMLINK if mylink.db is a symlink
SQLITE_CANTOPEN_SYMLINK (2062)

Fix 1

Why this works

Remove the SQLITE_OPEN_NOFOLLOW flag if symlinks are safe in your environment.

Fix 2

Why this works

Open the real path rather than the symlink.

Version notes

Sources

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

🔧 Source ref: sqlite3.h — SQLITE_CANTOPEN_SYMLINK = 2062

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 →