n8n prunes old execution data on its own: out of the box it keeps finished executions for 14 days, holds at most 10,000 of them, and deletes the rest in two steps. Four environment variables control that behaviour, and a fifth decides whether a SQLite database file ever gets smaller.
This guide lists every execution-data variable with its current default, shows a working Docker and Docker Compose setup, and explains what pruning actually does to your database. Everything was tested on a local n8n 2.47.7 instance (the stable release of November 13, 2026) with the default SQLite database: we fired real webhook executions at it, watched n8n’s own pruning logs, and measured the database before and after each step. The defaults were also checked against n8n’s source code for that version.
n8n Execution Data Environment Variables (Quick Reference)
These are the variables that decide what n8n stores and when it deletes it. Defaults are for n8n 2.47.7 and match n8n’s executions variables page.
| Variable | Default | What it does |
|---|---|---|
EXECUTIONS_DATA_PRUNE | true | Turns automatic pruning on or off. On by default since n8n 1.0 (2023). |
EXECUTIONS_DATA_MAX_AGE | 336 | Hours after an execution finishes before it can be pruned (336 hours = 14 days). Decimals work: 0.01 is 36 seconds. |
EXECUTIONS_DATA_PRUNE_MAX_COUNT | 10000 | Maximum number of executions to keep. The oldest go first. 0 means no limit. |
EXECUTIONS_DATA_HARD_DELETE_BUFFER | 1 | Hours a pruned execution waits, after being marked deleted, before it is physically removed. |
EXECUTIONS_DATA_PRUNE_SOFT_DELETE_INTERVAL | 60 | Minutes between checks that mark old executions as deleted. |
EXECUTIONS_DATA_PRUNE_HARD_DELETE_INTERVAL | 15 | Minutes between runs that physically delete marked executions. |
EXECUTIONS_DATA_SAVE_ON_SUCCESS | all | Save successful production executions (all) or not (none). |
EXECUTIONS_DATA_SAVE_ON_ERROR | all | Save failed executions (all) or not (none). |
EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS | true | Save executions you start from the editor. |
EXECUTIONS_DATA_SAVE_ON_PROGRESS | false | Save data after every node, not just at the end. Makes each run write much more. |
DB_SQLITE_VACUUM_ON_STARTUP | false | SQLite only: rebuild the database file at startup so deleted data stops taking disk space. |
Two rules decide when an execution is pruned, and either one is enough: it finished more than EXECUTIONS_DATA_MAX_AGE hours ago, or there are more than EXECUTIONS_DATA_PRUNE_MAX_COUNT executions in total. On a busy instance the count limit usually triggers long before 14 days have passed.
How to Configure Pruning in Docker, Docker Compose and npm
A sensible setup for a small self-hosted instance keeps a week of history, caps the table at 50,000 rows, keeps only failed production runs, and reclaims SQLite space on each restart. With docker run:
docker run -d --name n8n -p 5678:5678 \
-v n8n_data:/home/node/.n8n \
-e EXECUTIONS_DATA_PRUNE=true \
-e EXECUTIONS_DATA_MAX_AGE=168 \
-e EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000 \
-e EXECUTIONS_DATA_SAVE_ON_SUCCESS=none \
-e EXECUTIONS_DATA_SAVE_ON_ERROR=all \
-e DB_SQLITE_VACUUM_ON_STARTUP=true \
docker.n8n.io/n8nio/n8nThe same settings in docker-compose.yml:
services:
n8n:
image: docker.n8n.io/n8nio/n8n
ports:
- "5678:5678"
volumes:
- n8n_data:/home/node/.n8n
environment:
- EXECUTIONS_DATA_PRUNE=true
- EXECUTIONS_DATA_MAX_AGE=168
- EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000
- EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
- EXECUTIONS_DATA_SAVE_ON_ERROR=all
- DB_SQLITE_VACUUM_ON_STARTUP=true
volumes:
n8n_data:For an npm install, export the variables in the shell (or your systemd unit) before running n8n start. Environment variables are read at startup, so restart n8n after changing them. Drop EXECUTIONS_DATA_SAVE_ON_SUCCESS=none if you need a record of successful runs, for example for auditing. If you are still choosing where to run n8n, see the options for self-hosting n8n and the step-by-step n8n on AWS EC2 with Docker guide.
How n8n Pruning Actually Works
Each saved execution is a row in the execution_entity table, with its payload (the input and output of every node) in execution_data and any files in binary storage. Pruning removes all three, but not in one go:

- Soft delete. Every 60 minutes, n8n sets a
deletedAttimestamp on executions that break the age or count rule. They disappear from the Executions list at once, but they are still in the database. - Hard delete. Every 15 minutes, n8n removes executions whose
deletedAtis older than the buffer (1 hour), in batches of 100, together with their payload and binary data. In n8n’s source the buffer is counted from the moment of the soft delete, not from when the execution finished. - Disk space. On PostgreSQL the freed space is reused by the table. On SQLite it becomes free pages inside the file: the file stays the same size until a VACUUM rebuilds it.
Three kinds of execution are never pruned: those still in the new, running or waiting state, and annotated executions (ones you have tagged or rated in the Executions view). Annotated executions are also left out when the count limit is worked out, so they do not count towards EXECUTIONS_DATA_PRUNE_MAX_COUNT.
What We Saw When We Tested It
The test instance ran one workflow: a Webhook trigger followed by a Code node that returns a 20 KB string, so each execution adds a measurable amount of data. To see results in minutes instead of hours, we shortened the two intervals to 1 minute (both accept any number of minutes). We turned on n8n’s debug logs for pruning with N8N_LOG_LEVEL=debug and N8N_LOG_SCOPES=pruning, and counted rows with the sqlite3 command-line tool.
Count limit: 200 executions pruned down to 50
With EXECUTIONS_DATA_PRUNE_MAX_COUNT=50 and the buffer set to 0, we called the webhook 200 times. Within a minute n8n logged:
09:37:16.253 debug Soft-deleted executions { "scopes": ["pruning"], "count": 150, "file": "executions-pruning.service.js", "function": "softDelete" }
09:37:17.282 debug Hard-deleted executions { "scopes": ["pruning"], "count": 150, "file": "executions-pruning.service.js", "function": "hardDelete" }The table went from 200 rows to exactly 50. The database file did not change at all: 6,864,896 bytes before and after (plus a 4.2 MB write-ahead log). When n8n stopped and folded the log into the main file, it was 7.5 MB for just 50 executions. That is the SQLite behaviour explained in the next section.
Age limit and the one-hour buffer
On a fresh instance we set EXECUTIONS_DATA_MAX_AGE=0.01 (36 seconds), turned the count limit off with 0, left the buffer at its default of 1 hour, and sent 20 requests. At the next soft-delete pass n8n logged Soft-deleted executions { "count": 20 }. The Executions list was now empty, but the table still held all 20 rows and all 20 payloads, and the hard-delete runs that followed removed nothing. That is the buffer at work: if a pruned execution vanishes from the UI, its data stays on disk for at least another hour.
Why the n8n Database Doesn’t Shrink After Pruning (SQLite)
SQLite never gives disk space back to the operating system by itself. Deleted rows become free pages that SQLite reuses for new data, so a pruned database stops growing but keeps its peak size. To shrink the file you need a VACUUM, which rebuilds the database into a new, compact file. This is the measured sequence from our test, with 50 executions kept and 300 pruned:
| Step | File size | Executions in table | Free pages |
|---|---|---|---|
| 300 executions soft-deleted (hidden in the UI) | 11.02 MB | 350 | 0 |
| After the hard-delete pass | 11.01 MB | 50 | 1,674 of 2,689 |
After one restart with DB_SQLITE_VACUUM_ON_STARTUP=true | 4.16 MB | 50 | 0 |
Hard deletion emptied 62% of the file without changing its size. One restart with the vacuum option cut it from 11.01 MB to 4.16 MB. Some practical points:
- VACUUM slows startup. It runs while n8n starts, and on a database of several gigabytes it can take minutes. In our test n8n’s health endpoint already answered while the VACUUM was still running, so don’t treat a passing health check as proof that the vacuum is done.
- It needs free disk space. According to SQLite’s documentation, VACUUM can need up to twice the size of the database in free space while it works. A disk that is already full can’t be fixed this way; free some space first.
- Only already-deleted data is reclaimed. If executions are only soft-deleted (still inside the buffer), VACUUM has nothing to remove. In one of our runs we restarted before the hard delete had happened, and the vacuum shrank the file by just 8 KB.
- You don’t have to leave it on. Many people set it to
truefor one restart after a big cleanup and then turn it off again, to keep restarts fast.
To run a VACUUM by hand instead, stop n8n, back up the file, and use the sqlite3 tool on it. In the official Docker image the database is at /home/node/.n8n/database.sqlite inside the volume:
# stop n8n first, then:
cp database.sqlite database.sqlite.bak
sqlite3 database.sqlite "VACUUM;"
sqlite3 database.sqlite "PRAGMA page_count; PRAGMA freelist_count;"A freelist_count of 0 means there is no unused space left in the file.
What about PostgreSQL?
PostgreSQL handles this differently. Deleted rows are cleaned up by its autovacuum process and the space is reused by the same table, so the database stops growing once pruning keeps the row count steady. Plain VACUUM does not return space to the operating system either; only VACUUM FULL rewrites the table to its minimum size, and it locks the table while it runs, so schedule it for a maintenance window. DB_SQLITE_VACUUM_ON_STARTUP has no effect on PostgreSQL.
Save Less Execution Data in the First Place
Pruning cleans up after the fact. The bigger win is not storing data you’ll never look at:
EXECUTIONS_DATA_SAVE_ON_SUCCESS=none: don’t keep successful production runs. Failed runs are still saved, which is what you need for debugging.EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false: don’t keep the test runs you start from the editor.- Leave
EXECUTIONS_DATA_SAVE_ON_PROGRESSatfalse. Turning it on saves the execution after every node, which multiplies database writes. - Per workflow: open the workflow, go to Options → Settings, and set Save successful production executions to Do not save. This overrides the global variable for that workflow only, which is useful for one high-volume webhook workflow.
One detail we noticed in testing: with EXECUTIONS_DATA_SAVE_ON_SUCCESS=none, n8n 2.47.7 still writes each run to the database while it executes, then marks it as deleted with a timestamp already one buffer-length in the past. After 25 successful runs the table held 25 rows, all marked deleted and none visible in the UI, and the next hard-delete pass removed all 25 along with their payloads. So unsaved runs can sit on disk for up to one hard-delete interval (15 minutes by default). n8n’s source shows that if pruning is turned off, unsaved runs are deleted immediately instead.
How to Delete n8n Executions Manually
Sometimes you need space back now, or want to clear the execution history before handing an instance over. There are three ways, from safest to most hands-on.
From the Executions list
Open Executions, filter by workflow, status or date if you need to, select the runs (or select all), and delete them. Unlike pruning, this skips the soft-delete step: n8n’s code removes the selected executions, their payloads and their binary data straight away. On SQLite, follow it with a VACUUM if you want the file to shrink.
With the n8n API
The public API has a delete endpoint, which is handy for scripts. Create an API key under Settings → n8n API, then:
curl -X DELETE "https://your-n8n.example.com/api/v1/executions/1234" \
-H "X-N8N-API-KEY: $N8N_API_KEY"List executions first with GET /api/v1/executions (it accepts filters such as status, workflowId and startedBefore) to collect the IDs.
With SQL: let n8n do the deleting
Older guides suggest running DELETE FROM execution_entity directly. We tested that on a copy of a SQLite database holding 20 executions, and it leaves the real data behind:
$ sqlite3 copy.sqlite "SELECT COUNT(*) FROM execution_entity; SELECT COUNT(*) FROM execution_data;"
20
20
$ sqlite3 copy.sqlite "DELETE FROM execution_entity WHERE stoppedAt < datetime('now');"
$ sqlite3 copy.sqlite "SELECT COUNT(*) FROM execution_entity; SELECT COUNT(*) FROM execution_data;"
0
20The executions were gone but all 20 payload rows in execution_data stayed. The sqlite3 tool has foreign keys switched off by default, so the ON DELETE CASCADE rule never ran. With PRAGMA foreign_keys = ON; in the same command, both tables were emptied. Even then, a raw delete skips binary files on disk and any payloads stored outside the database (n8n can keep execution data on the filesystem or in S3 via N8N_EXECUTION_DATA_STORAGE_MODE).
A safer approach is to do only the first step yourself: mark the executions as deleted, with a timestamp older than the buffer, and let n8n’s next hard-delete pass remove everything properly. Back up the database first. On SQLite:
sqlite3 database.sqlite "UPDATE execution_entity
SET deletedAt = STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW', '-2 hours')
WHERE status NOT IN ('new', 'running', 'waiting')
AND stoppedAt < STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW');"This marks every finished execution. To keep recent ones, compare stoppedAt with an earlier time instead of now, for example STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW', '-7 days'). In our test the instance held 30 executions and 30 payload rows; about a minute after the update, n8n logged Hard-deleted executions { "count": 30 } and both tables were empty. With default settings it happens within 15 minutes. On PostgreSQL the same idea works with NOW() - INTERVAL '2 hours'.
If you want to wipe a self-hosted instance completely, including workflows and credentials, deleting the .n8n folder (or the Docker volume) does that. It is irreversible, so export your workflows first with n8n export:workflow --all --output=backup.json.
Execution Retention on n8n Cloud
On n8n Cloud you can’t set these environment variables. n8n prunes automatically, oldest first, and the limits depend on the plan, according to n8n’s Cloud data management docs:
| Plan | Max saved executions | Max log retention |
|---|---|---|
| Starter | 2,500 | 7 days |
| Pro | 25,000 | 30 days |
| Enterprise | 50,000 | Unlimited |
What you can control is what gets saved: in the Cloud console, open Instance settings and, under Executions to save, deselect Manual, Failed or Successful, then save and restart. The per-workflow setting described above works on Cloud too.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Pruning is on but the database file is still huge | SQLite keeps freed pages inside the file | Restart once with DB_SQLITE_VACUUM_ON_STARTUP=true, or VACUUM manually with n8n stopped |
| Executions vanished from the UI but disk use didn’t drop | They are soft-deleted and waiting out the 1-hour buffer | Wait for the next hard-delete pass after the buffer, then VACUUM |
| History is shorter than 14 days | The 10,000-execution count limit was reached first | Raise EXECUTIONS_DATA_PRUNE_MAX_COUNT or set it to 0 and rely on age alone |
| Some old executions are never deleted | They are annotated (tagged or rated), or still waiting | Remove the annotation, or finish or stop the waiting execution |
| The database keeps growing with pruning on | EXECUTIONS_DATA_PRUNE=false is set somewhere, or each run is very large | Check the container environment; stop saving successful runs and avoid saving progress |
| n8n takes minutes to start | DB_SQLITE_VACUUM_ON_STARTUP=true on a large database | Turn it off after the cleanup restart |
Execution history is also only one source of growth. If your workflows handle files, binary data can be larger than the execution payloads, and pruning removes it only from the storage mode currently in use. For Kubernetes deployments, see how we ran n8n on Kubernetes.
Conclusion
n8n already prunes execution data by default: finished executions older than 14 days, or beyond the newest 10,000, are first hidden (soft-deleted) and then removed for good after a one-hour buffer. Tune that with EXECUTIONS_DATA_MAX_AGE and EXECUTIONS_DATA_PRUNE_MAX_COUNT, and store less with EXECUTIONS_DATA_SAVE_ON_SUCCESS=none. On SQLite, remember that pruning stops the growth but doesn’t shrink the file: one restart with DB_SQLITE_VACUUM_ON_STARTUP=true took our test database from 11.01 MB to 4.16 MB. When you need to delete executions by hand, use the UI, the API, or a SQL update that marks rows deleted, not a raw DELETE.
FAQs
Is n8n execution data pruning enabled by default?
Yes. Since n8n 1.0 (2023), EXECUTIONS_DATA_PRUNE defaults to true. n8n keeps finished executions for 336 hours (14 days) or up to 10,000 executions, whichever limit is reached first.
What does EXECUTIONS_DATA_MAX_AGE do?
It sets how many hours after an execution finishes it becomes eligible for pruning. The default is 336 hours (14 days). Set 168 for 7 days or 720 for 30 days. Decimal values work too.
What does EXECUTIONS_DATA_PRUNE_MAX_COUNT do?
It caps the number of executions kept in the database; the default is 10,000. When there are more, n8n prunes the oldest first. Set it to 0 to disable the count limit and prune by age only. Annotated executions are not counted.
Why is my n8n SQLite database still large after pruning?
SQLite keeps the space of deleted rows inside the file and reuses it. Set DB_SQLITE_VACUUM_ON_STARTUP=true and restart n8n once, or stop n8n and run sqlite3 database.sqlite “VACUUM;” to rebuild the file at its real size.
How do I delete all executions in n8n?
In the Executions list, select all and delete; n8n removes them immediately. For scripts, use DELETE /api/v1/executions/{id} with an API key. Avoid a raw SQL DELETE on SQLite: without foreign keys enabled it leaves the execution payloads behind.
Does EXECUTIONS_DATA_SAVE_ON_SUCCESS=none stop executions from being written?
Not entirely. In n8n 2.47.7 the run is written while it executes, then marked deleted as soon as it succeeds, so it never appears in the UI and is removed at the next hard-delete pass (every 15 minutes by default). Failed runs are still saved.
Can I change pruning settings on n8n Cloud?
No, n8n Cloud applies plan limits: 2,500 executions and 7 days on Starter, 25,000 and 30 days on Pro, 50,000 and unlimited retention on Enterprise. You can choose which execution types to save in the Cloud console or in each workflow’s settings.








