Hi everyone,
I’m currently building an automation system in n8n Cloud and ran into a serious issue today.
While designing a workflow with the help of ChatGPT, part of the logic unintentionally created a loop. This caused the workflow to execute repeatedly and ended up consuming all of my monthly executions — including those from a plan I had just upgraded to today.
As a result, my workflows are now no longer running.
I’ve already identified and corrected the loop in the workflow, so this shouldn’t happen again. However, I would really appreciate your guidance on the following:
1. Is there any way to restore or recover the consumed executions in cases like this?
2. Are there best practices to prevent this type of infinite loop from happening again in n8n?
3. Is there any built-in safeguard or configuration I should implement to protect against this in the future?
This is part of a real project I’m actively building, so I want to make sure I set things up correctly going forward.
Thanks a lot in advance for your help — I really appreciate the support from the community.
Describe the problem/error/question
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
For the executions thing i would reach out to help.io, theyve done one-time resets before for accidental loops. Going forward set a timeout in your workflow settings so a runaway execution gets killed automatically.
for ai-generated logic especially, its worth testing with the workflow deactivated first and manually triggering a few runs before going live. also adding a counter to any loop with an exit condition after N tries — even broken logic has a ceiling that way. learned that one the hard way tbh
for executions recovery — contact n8n support directly, they do reset execution counts for accidental loops, especially when it happens right after an upgrade. just explain the situation and they usually sort it out.
for future protection, @Benjamin_Behrens’s counter tip is the right approach. concrete way to do it: add a Code node at the start of any loop-prone workflow with something like this:
js
const data = $workflow.staticData;
data.runCount = (data.runCount || 0) + 1;
if (data.runCount > 50) {
data.runCount = 0;
throw new Error('Safety limit hit — workflow stopped itself');
}
return $input.all();
```
the throw stops the execution cleanly and shows up in your execution log. also worth setting a workflow-level timeout in Settings — that's your last line of defense if the counter somehow doesnt catch it.
that staticData approach is clean — the counter persists across executions so it even survives n8n restarts, which matters for scheduled workflows. the reset before the throw is the right call too, otherwise you’d be locked out permanently after fixing the issue. counter + timeout together is solid two-layer defense.