Question

SQLite works locally, breaks on Vercel with 'unable to open database file'

Solved · 7 views · asked by kai_makes · edited

My app uses a data.db file next to the code. Locally fine. On Vercel every request fails.

SqliteError: unable to open database file
What I’ve tried

Set the path to ./data.db, /tmp/data.db, and an absolute path. Committed the file to git.

Comment

1 answer

Marked as helpful by the asker
ines_data · edited

Vercel functions are read-only and stateless: the filesystem resets on every deploy and every cold start. A file database cannot live there.

Options by effort:

  • Turso (hosted SQLite, has a free tier, same SQL): change the connection string, done.
  • Supabase/Neon Postgres: more setup, more room to grow.

/tmp "works" until the function recycles, then your data is gone. Do not ship that.

Comment