Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

SQLite in Production with Prisma and pm2: Fixing “Database Is Locked”

A production SQLite lock incident involved DELETE journal mode, duplicate pm2 processes, competing Prisma connections, stale environment values, and unsafe backup handling. Here’s what to check—and what WAL and timeouts can’t fix.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Intermittent SQLite lock errors in a Prisma app managed by pm2 can come from several interacting causes—not just a missing timeout. In one reported production incident, the database used SQLite’s default DELETE journal mode, two pm2 processes were writing to the same file, and Prisma connections competed for locks. The author’s remedy was to enable WAL, remove the duplicate process, limit the connection pool, set a timeout, correct the environment values actually used by the app, and switch to SQLite-aware backups. Those changes address that deployment’s symptoms; they are not a universal configuration recipe.

What the incident looked like

An escrow marketplace running Next.js, Prisma, and a single SQLite file began returning occasional HTTP 500 responses. Prisma operations timed out while waiting for the database, and a nightly backup failed with Error: database is locked. In an incident report dated September 26, 2026, the author traced the trouble to three conditions: DELETE journal mode, two online pm2 processes with the same app name, and competing Prisma connections. The report discloses AI assistance based on the author’s incident notes and commands; the diagnosis and outcome are the author’s account, not an independently reproduced test. Read the incident report.

As an Amazon Associate I earn from qualifying purchases.

Check the database and process before changing settings

Verify the journal mode

Run PRAGMA journal_mode; against the same database file the application uses. The incident author found delete. SQLite connections default to DELETE mode; WAL can be enabled with PRAGMA journal_mode=WAL; when the database’s VFS supports it. Confirm the result after changing it rather than assuming the command applied. SQLite’s WAL documentation describes the mode and its behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check for duplicate pm2 processes

The author says pm2 list looked normal, while pm2 jlist showed two online processes with the same application name. They removed the extra process and saved the intended process list so it would not return after reboot. Treat this as a diagnostic lead, not evidence that pm2 routinely creates duplicate processes: inspect your own process list and deployment setup before removing anything.

Confirm the effective environment and database path

Changing a project’s .env file may not change the values already used by a running deployment. In this incident, the author found separate environment values in pm2’s ecosystem configuration and a Next.js standalone build; reloading with an old stored environment could preserve the old value. Inspect the running application’s effective DATABASE_URL, the database file path it resolves to, the pm2 ecosystem configuration, and the environment included in the deployed build. Make sure every process points to the intended file before adjusting lock behavior.

What WAL changes—and what it cannot

WAL (write-ahead logging) usually allows readers and a writer to proceed concurrently, which can reduce reader/writer blocking compared with rollback journaling. It does not allow multiple simultaneous writers. SQLite states: “There can only be one writer at a time.” If several application processes write concurrently, they still contend for that single writer slot. SQLite: Write-Ahead Logging.

Rank #2

WAL also has a deployment boundary: participating processes need shared memory, so WAL is not designed for a database accessed across hosts over a network filesystem. Use it only where the database and its accessing processes meet SQLite’s same-host requirements. If the workload needs concurrent writers or cross-host database access, changing journal mode alone does not make this SQLite deployment model suitable.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Connection limits and timeouts: wait, don’t expect more writers

The incident author reports setting connection_limit=1 and socket_timeout=10 in DATABASE_URL. These are the author’s settings for their deployed Prisma setup, not a verified prescription for every Prisma version. Check the documentation for the Prisma version you actually deploy before adopting those URL parameters. In particular, do not treat Prisma’s reported socket_timeout as equivalent to SQLite’s C-level busy timeout.

A busy timeout is a bounded wait-and-retry policy: SQLite sleeps and retries while a table is locked, then can return SQLITE_BUSY once the configured cumulative sleep limit has elapsed. A longer wait can help when contention is brief. It cannot raise SQLite’s one-writer limit or guarantee that a lock clears before the wait expires. SQLite: Set A Busy Timeout.

Back up a live database as database state

While a connection is open in WAL mode, SQLite may use a -wal file; the associated -shm file may also be present. The WAL file can contain committed transactions and is part of the database’s persistent state. Separating it from the main database file can lose transactions or corrupt the database, so copying only the live .db file is not a sound backup strategy.

Use a SQLite-supported live backup method, such as the Online Backup API or the shell’s .backup command if the SQLite shell build you use provides it. SQLite warns that an external file-copy approach can make writers wait and may leave a corrupted backup after a system failure. Validate a backup with PRAGMA integrity_check; and test that your restore process works. After restoring an older snapshot, the incident author recommends checking PRAGMA journal_mode; again; a snapshot created before the WAL change may not retain the mode you expect. SQLite: Online Backup API explains live snapshots and the limits of external copying.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to apply the incident’s lessons

  1. Identify the exact database. Check the effective environment and resolved database path in the deployed application, not just the local .env file.
  2. Inspect the deployment. Check the pm2 process list for unintended duplicate instances, then confirm which processes can write to the same database.
  3. Check journal mode. Query PRAGMA journal_mode;; consider WAL if the deployment is on a compatible same-host filesystem and its concurrency profile benefits from reader/writer overlap.
  4. Verify Prisma settings for your version. If adjusting connection limits or timeout parameters, use the documentation for the deployed Prisma version and distinguish client-level settings from SQLite busy-timeout behavior.
  5. Use a safe backup path. Back up with SQLite-aware tooling, validate the resulting database, and confirm the restore procedure and journal mode.
  6. Observe before declaring the issue fixed. Watch application errors, backup completion, and database behavior under the workload that previously produced lock failures.

What the reported test does—and does not—show

The incident author says that after the changes, 24 concurrent Prisma writes succeeded in about 50 milliseconds in that deployment. This is a single reported test, not an independently reproduced benchmark or a general measure of SQLite capacity. It does not change SQLite’s one-writer-at-a-time constraint.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.