**SQLite stays permanently locked (SQLITE_BUSY) even with all workflows deactivated and the container fully paused — looking for real-world WAL migration experience**

Spent most of today trying to get a clean backup of our database.sqlite and I’m stuck, so figuring I’d ask before I go down the WAL rabbit hole blind.

Quick context: self-hosted, Docker Compose + Traefik, single container (not queue mode), n8n version 1.123.5. Database’s about 3.5GB, still on the default rollback journal mode, not WAL. Instance runs two clients’ workflows (tagged), fairly high Pipedrive/Calendly/CloudTalk/WebinarJam webhook volume during the day. We already back up the workflows themselves via the API on a cron, but I want an actual full database.sqlite snapshot too — credentials, encryption key, executions, the works in case the VPS disappears entirely.

Started simple: sqlite3 database.sqlite ".backup 'out.sqlite'". Straight up Error: database is locked, first try.

Fine, added .timeout — tried 10s, 30s, 60s. Still locked, every time, even after waiting the full minute.

Then wrote a small retry loop, 10 attempts, 30s apart, so like 5-8 minutes of just hammering at it. Not one attempt got through.

At that point I figured it had to be workflow traffic, so I pulled the list of active workflows (40 of them, across both clients), deactivated literally all of them through the API, waited, and ran the retry loop again for another 6 minutes with zero workflows active. Still locked. Every attempt. Reactivated everything after (double checked they all came back, they did).

Last thing I tried, kind of out of ideas at that point is docker pause’d the whole container and tried .backup while it was completely frozen. Failed instantly, before I even unpaused. Which honestly surprised me. I assumed a fully frozen container = zero write activity = no lock. Best guess now is that the file lock belongs to whatever connection was already holding it, and freezing the process doesn’t release it, it just freezes it mid-hold — so if the writer happened to be mid-transaction the moment I paused, that lock just sits there stuck for the whole pause. If that’s right then it’s basically down to luck whether a pause catches it idle or not, and today I never got lucky.

Went through a full day of docker logs after that trying to find whatever’s writing this much, filtered out all the bot/webhook noise. Found basically nothing — one single “Pruning old insights data” line, once, all day. Doesn’t line up with a lock that’s held for 45+ minutes straight across several separate tests. Checked recent executions through the API too and saw legit Pipedrive-webhook bursts every ~5s or so, but that can’t be it either since the lock didn’t budge even with everything deactivated.

So at this point whatever’s writing isn’t logging anything and isn’t tied to any workflow I can find, which is a bit unsettling.

A few things I’m hoping someone here has actually dealt with:

  • Anyone seen the db stay locked like this with literally zero active workflows? Any idea what internal n8n process could be holding a write open without printing anything — insights collection, pruning, license check-ins, connection pool stuff, anything?
  • Has anyone switched a live, busy production instance over to WAL (PRAGMA journal_mode=WAL;) without taking it down? Does n8n ever quietly reset the journal mode back on its own restart? Any issues with the -wal file just growing forever if checkpoints don’t happen?
  • And honestly — at what point do people here just give up on SQLite and move to Postgres instead of fighting it? Is there some rough size/traffic line where that’s obviously the right call?

Not trying to take the instance down to fix this, it’s running a live sales pipeline, so any pointers from people who’ve actually hit this welcome.

Hey @Igor_Ziemczyk, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@A_A4, @anon61017519, @Glorious - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

The docker pause test is the key clue here, and it points away from “n8n is actively writing” toward a stale/orphaned lock rather than live contention. A few things worth checking:

Check for a leftover journal file. With the default rollback-journal mode not WAL), an aborted transaction can leave a database.sqlite-journal file sitting next to the main db. If that file exists and is non-empty, SQLite treats it as an incomplete transaction and refuses further access, this would explain a lock that never clears no matter what you deactivate or pause, since nothing is actually “holding” it live, it’s just a permanent flag. Check with ls -la next to your db file. If present, back up first, then let SQLite’s own recovery handle it opening the db normally should auto-rollback and remove the journal, don’t delete it manually unless recovery genuinely won’t run).

Check your actual storage backend. SQLite’s file locking relies on POSIX advisory locks (fcntl), and these are notoriously unreliable or outright broken on network-backed filesystems (NFS especially, but some cloud “network volumes” too), locks can appear to persist forever because the lock state itself is inconsistent across the network layer, independent of any real writer. If your Docker volume is anything other than a plain local disk/EBS-style block volume, this is worth ruling out first, since it would explain exactly the pause-doesn’t-help symptom (the lock isn’t held by a live process at all).
lsof inside the container (or on the host if it’s a bind mount), lsof | grep database.sqlite, to see what actually has the file open. If nothing shows up holding it, that’s strong confirmation this is a stale journal/filesystem issue, not a live process.

On your direct questions: n8n’s own insights/pruning writes are logged (as you saw), and don’t hold locks anywhere near that long, 45+ minutes of unresponsiveness with zero write log activity is not normal n8n behavior at any traffic level you’re describing. I wouldn’t chase WAL migration until you’ve ruled out #1 and #2 above, since WAL won’t help if the actual problem is a stuck stale lock or an unreliable filesystem, it’ll just move the same failure mode to a -wal file instead.

On the Postgres question: given you’re running two clients’ production sales pipelines off a 3.5GB SQLite file already hitting hard lock issues, that’s well past the point people typically switch, SQLite’s single-writer model doesn’t scale gracefully once you have concurrent write-heavy workflows from multiple sources, which is exactly your setup.

We have taken a look at this and it looks like it might be fixed in a recent release, Please update and see if you are still running into the same problem.

Hi @Igor_Ziemczyk
n8n sets the journal mode itself when it opens the file, from DB_SQLITE_POOL_SIZE, so a manual PRAGMA journal_mode=WAL is not how you get WAL on an n8n instance. Set the variable above zero and restart the container, the pooling driver then opens the database in WAL with one write connection and that many read connections:

DB_SQLITE_POOL_SIZE=4

In WAL a reader no longer waits behind the writer, so sqlite3 database.sqlite ".backup 'out.sqlite'" runs against the live file instead of returning busy. This is also where n8n is heading, in 2.0 the legacy driver is removed and the pooling driver becomes the default with a pool size of 2.

Thanks everyone who replied above. Genuinely appreciate the input, still going to read through the suggestions properly since some of it’s probably worth doing anyway. But figured it out on my own before I got a chance to try any of it, so posting what actually worked in case it saves someone else the same afternoon.

Update for anyone finding this later: didn’t end up needing WAL at all. Solution ended up being simpler than everything above, and honestly a bit obvious in hindsight.

docker pause on its own didn’t fix anything, like I said: .backup still failed instantly even fully frozen. But the reason for that is .backup still has to go through SQLite’s own locking, and that lock apparently survives a freeze if a writer was mid-transaction when you paused it. What actually works: docker pause, then a plain cp -a of the whole data directory (not .backup, not sqlite3 at all), then docker unpause. Plain cp doesn’t ask SQLite for anything, it just reads bytes off disk, so it never hits the lock in the first place.

Didn’t just trust that in theory though. I’ve copied the frozen snapshot to a totally separate machine, mounted it into a fresh throwaway n8n container, and started it up. First line in the logs was literally Last session crashed, which is n8n correctly detecting exactly the situation described above. It ran its recovery/migration on startup like normal and came up clean with the full, real workflow list (in our case, north of 200 workflows including inactive ones). Full working restore, not just a file that passes PRAGMA integrity_check.

Total freeze time was a bit over 2 minutes for a ~3.5GB data dir. Traefik/n8n’s socket stays open while paused, so anything hitting a webhook during that window just sits waiting instead of getting an immediate rejection — much gentler than what we saw earlier when we tried deactivating every workflow instead (that just returns “webhook not registered” instantly, which is worse).

So: docker pause + cp + docker unpause, skip .backup entirely, works, no WAL needed. Might still switch to WAL down the line since it’d get rid of the freeze window entirely, but wasn’t the blocker I thought it’d be.

Figured this’d come up so posting it separately: the obvious alternative to all of this is docker stop, copy, docker start would’ve dodged the SQLite lock just as well. Didn’t go that route for basically one reason, and it’s not really a technical one: I don’t trust restarts on this particular box, because it’s bitten me before and it wasn’t small. One of the first times I ever restarted this n8n container, it came back up with the database rolled back to a snapshot from about a month earlier and lost every workflow I’d built since. Never fully figured out why, just know it happened once, and I don’t have a solid backup underneath this to fall back on if it happens again. That’s the whole reason I was trying to get a proper database backup working in the first place today. Even a server-level backup from the hosting provider wouldn’t really save me here: if the box itself goes down, all I’d get back is whatever their last snapshot was, and by the time I’d actually need it that could be about as stale as what I lost last time. So a restart isn’t a “probably fine” thing for me, it’s something I go out of my way to avoid unless there’s no other option. pause never touches the running process at all, so none of that risk applies, and that’s really the whole reason I went with it instead (my hosting is Hostinger btw)

Went and checked both things you pointed at, and you were right on the money.

database.sqlite-journal is still sitting there, 58MB now. But its own last modified time is hours behind the main database.sqlite file, which keeps changing right along like normal. So it’s not actively growing anymore, it’s just sitting there stale. Matches what you said about an aborted transaction leaving that file behind rather than something actively writing the whole time.

Ran lsof too. Every handle on both files, database.sqlite and the journal, traces back to a single process, the main n8n node process, just spread across a bunch of its own threads (libuv workers, a DelayedTask handler, that kind of thing). So no rogue second process holding anything, it really is n8n itself.

Checked DB_SQLITE_POOL_SIZE while I was at it since Anshul mentioned it further down, and it’s not set at all here, running on whatever the default is.

Not touching anything else on this box today though, don’t want to risk it going sideways right before Monday morning when the whole sales team is back on it. But this gives me something solid to actually dig into properly when I’ve got a calmer window. Appreciate you pointing me at the right two things instead of me guessing.