# Problem in n8n loop node

**URL:** <https://community.n8n.io/t/problem-in-n8n-loop-node/41200>\
**Category:** Questions\
**Tags:** node, looping, loop-over-items\
**Created:** [February 29, 2024, 5:33am UTC](https://community.n8n.io/t/problem-in-n8n-loop-node/41200 "2024-02-29T05:33:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhojraj\_Pilaniya](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bhojraj_pilaniya/32/36246_2.png) [@Bhojraj\_Pilaniya](https://community.n8n.io/u/Bhojraj_Pilaniya)\
**Post date:** [February 29, 2024, 5:33am UTC](https://community.n8n.io/t/problem-in-n8n-loop-node/41200/1 "2024-02-29T05:33:45Z")

</div>

I have problems with workflows where there is a loop in a loop, the 2ndory loop has issues, becauses it marks all incoming inputs as done before looping them. I even tried reset but it does not work, it only processes 1st input , everytrhing else is passe

- **Version 1.21.1**
- **Database (default: SQLite):**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via n8n cloud**
- **Windows**

---

<div class="post-metadata">

**Author:** ![n8n](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/n8n/32/196425_2.png) [@n8n](https://community.n8n.io/u/n8n)\
**Post date:** [February 29, 2024, 5:33am UTC](https://community.n8n.io/t/problem-in-n8n-loop-node/41200/2 "2024-02-29T05:33:46Z")

</div>

It looks like your topic is missing some important information. Could you provide the following if applicable.

- **n8n version:**
- **Database (default: SQLite):**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):**
- **Operating system:**

---

<div class="post-metadata">

**Author:** ![bartv](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bartv/32/156374_2.png) [@bartv](https://community.n8n.io/u/bartv)\
**Post date:** [February 29, 2024, 7:27am UTC](https://community.n8n.io/t/problem-in-n8n-loop-node/41200/3 "2024-02-29T07:27:15Z")

</div>

Hi Bhojraj, welcome to the community!

Could you please share your workflow here so we can take a look at it? Just click the ‘\</\>’ button and paste your code in.

---

<div class="post-metadata">

**Author:** ![Bhojraj\_Pilaniya](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/bhojraj_pilaniya/32/36246_2.png) [@Bhojraj\_Pilaniya](https://community.n8n.io/u/Bhojraj_Pilaniya)\
**Post date:** [February 29, 2024, 8:36am UTC](https://community.n8n.io/t/problem-in-n8n-loop-node/41200/4 "2024-02-29T08:36:03Z")

</div>



---

<div class="post-metadata">

**Author:** ![Cristian\_DF](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/cristian_df/32/34350_2.png) [@Cristian\_DF](https://community.n8n.io/u/Cristian_DF)\
**Post date:** [February 29, 2024, 10:19am UTC](https://community.n8n.io/t/problem-in-n8n-loop-node/41200/5 "2024-02-29T10:19:35Z")

</div>

Have same problem, reported issue in Git #8764

> <https://github.com/n8n-io/n8n/issues/8764>
>
> \### Bug Description
> 
> I have been looking at this for hours. I am using N8N onlin…e version v1.29.1
> 
> I have a Loop inside another Loop and the problem is that the second Loop only runs once. For example if there are 4 items, it will loop 4 times but only once on the 'Loop Branch', the other 3 goes to 'Done Branch'. So it recognizes the items, but for some reason it takes data from a Node inside the Loop, so it is mixing data.
> 
> What i do is simple. I am creating Terms for different Taxonomies for WordPress. So I have an initial Loop for Taxonomies, and then a second loop for each Term not present in WP. I attach a screenshot.
> 
> Both Loop data is perfect, I just can't make it create more then 1 Term in each execution.
> Have a look at this JSON, it is the Output of the Loop Node, you will instantly see the problem:
> 
> \`\`\`
> \[
> {
> "new\_terms": {
> "time\_prepare": \[
> {
> "term": 634
> }
> \]
> }
> },
> {
> "term": "Almuerzos vegetarianos"
> },
> {
> "term": "Comida balanceada"
> },
> {
> "term": "fusilli"
> },
> {
> "term": "vegetariano"
> },
> {
> "term": "hervido"
> },
> {
> "term": "horneado"
> },
> {
> "term": "España"
> },
> {
> "term": "recetas fáciles almuerzo"
> }
> \]
> \`\`\`
> 
> The first Object in the Array, that contains 'new\_terms' should NOT be there. It comes from a Code Node (named Store - WP Term) inside the second loop right at the end of the loop.
> 
> !\[n8n-loop-inside-loop-finnishes-abruptly\](https://github.com/n8n-io/n8n/assets/100019968/7aee08e7-02c5-45a3-8c4c-74fb308b15d5)
> 
> 
> \### To Reproduce
> 
> \-
> 
> \### Expected behavior
> 
> \-
> 
> \### Operating System
> 
> online version
> 
> \### n8n Version
> 
> 1.29.1
> 
> \### Node.js Version
> 
> online version
> 
> \### Database
> 
> SQLite (default)
> 
> \### Execution mode
> 
> main (default)

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [February 29, 2024, 1:24pm UTC](https://community.n8n.io/t/problem-in-n8n-loop-node/41200/6 "2024-02-29T13:24:06Z")

</div>

Hey @Bhojraj_Pilaniya,

Looping in a loop can be tricky, It looks like you have worked out part of the trick with multiple loops by looping back from the order table but there there are a couple of issues here, The first one is the initial loop will run more times than expected because the if branch is looping back as well as the airtable node.

If you look at the example below…

The top part will run the first loop node 6 times because it is one for each input +1 for the done output but the bottom branch that goes from the If like you have to the Loop is running 9 times which is the output from the Replace Me 2 + The output of the false Branch + 1 for the done output.

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/4/c/4ced875b57b97cc4223542f054642ea6ce39b7b9.jpeg)

With the other part of this with the Loop outputting the data to done instantly this is likely to be because there are multiple executions coming in to the node like the example flow above. Typically we don’t recommend using nested loops like this as it can cause issues and a better way to handle it is to use a sub workflow so in this case you would move the second loop into its own workflow then call that workflow and you won’t need to loop back on it.

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [February 29, 2024, 4:11pm UTC](https://community.n8n.io/t/problem-in-n8n-loop-node/41200/7 "2024-02-29T16:11:42Z")

</div>

Good news, This may be resolved shortly with this PR: [feat(Loop Over Items (Split in Batches) Node): support multiple runs by elsmr · Pull Request #8777 · n8n-io/n8n · GitHub](https://github.com/n8n-io/n8n/pull/8777)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [May 29, 2024, 4:11pm UTC](https://community.n8n.io/t/problem-in-n8n-loop-node/41200/8 "2024-05-29T16:11:57Z")

</div>

Closed on May 29, 2024, 4:11pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
