Can't process a matrix of hosts in n8n

I’m trying to make a ping to a list of hostnames using n8n. When I try to process all a matrix of hostnames to make a ping (execute command) to each of them, it only runs the first one. I tried to change ips and hostbnames to a false one in order to make all of them fail. But once a run the workflow, it only sends one message, and not one for each of them

My workflow:

{
“name”: “ping win10.casa.lan”,
“nodes”: [
{
“parameters”: {},
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
-16,
176
],
“id”: “2cc7bd68-c4af-46c3-bbf9-e96933146aaa”,
“name”: “When clicking ‘Execute workflow’”
},
{
“parameters”: {
“executeOnce”: false,
“command”: “=ping {{ $node[“Code”].json.ip }} -c 1 -w 2”
},
“type”: “n8n-nodes-base.executeCommand”,
“typeVersion”: 1,
“position”: [
208,
0
],
“id”: “14cfe735-1781-4ffb-a294-41c490c95660”,
“name”: “Execute Command”,
“retryOnFail”: true,
“maxTries”: 5,
“notesInFlow”: true,
“alwaysOutputData”: true,
“onError”: “continueRegularOutput”
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 3
},
“conditions”: [
{
“id”: “191a559b-d587-4da1-8825-b78a70b85fc1”,
“leftValue”: “={{ $json.exitCode }}”,
“rightValue”: 0,
“operator”: {
“type”: “number”,
“operation”: “equals”
}
}
],
“combinator”: “and”
},
“options”: {}
},
“type”: “n8n-nodes-base.if”,
“typeVersion”: 2.3,
“position”: [
416,
0
],
“id”: “4ce670d4-a5be-4e5d-8806-6c66b375378e”,
“name”: “If”
},
{
“parameters”: {
“rule”: {
“interval”: [
{
“field”: “minutes”
}
]
}
},
“type”: “n8n-nodes-base.scheduleTrigger”,
“typeVersion”: 1.3,
“position”: [
-32,
-192
],
“id”: “4f4e6daa-b31f-47ed-9e7f-25383d52e90f”,
“name”: “Schedule Trigger”,
“retryOnFail”: true,
“maxTries”: 5,
“onError”: “continueRegularOutput”
},
{
“parameters”: {
“chatId”: “1418784730”,
“text”: “=✅ SISTEMA RECUPERADO :white_check_mark:\n-------------------------\n​:desktop_computer: Host: win10.casa.lan\n🟢 Estado: Responde correctamente al ping.\n🕒 Hora: {{ $now.format(‘HH:mm:ss’) }}”,
“additionalFields”: {}
},
“type”: “n8n-nodes-base.telegram”,
“typeVersion”: 1.2,
“position”: [
736,
-160
],
“id”: “f0a56d75-7242-433c-8c66-9c08fa97b772”,
“name”: “Nodo win10.casa.lan funciona ok”,
“webhookId”: “6a00e18b-af14-40e3-8d4b-8674a0749edb”,
“credentials”: {
“telegramApi”: {
“id”: “yTQIG4ElUvSauo9r”,
“name”: “Telegram account”
}
},
“disabled”: true
},
{
“parameters”: {
“chatId”: “1418784730”,
“text”: “=⚠️ Servidor Caído: {{ $item(0).$node[“Code”].json.nombre }} ({{ $item(0).$node[“Code”].json.ip }}) no responde a las {{ $now.format(‘HH:mm’) }}”,
“additionalFields”: {}
},
“type”: “n8n-nodes-base.telegram”,
“typeVersion”: 1.2,
“position”: [
752,
128
],
“id”: “09f1f42e-9ef5-4865-b162-4ea9d9ad7072”,
“name”: “Nodo win10.casa.lan no responde a ping”,
“webhookId”: “6a00e18b-af14-40e3-8d4b-8674a0749edb”,
“executeOnce”: false,
“retryOnFail”: true,
“credentials”: {
“telegramApi”: {
“id”: “yTQIG4ElUvSauo9r”,
“name”: “Telegram account”
}
}
},
{
“parameters”: {
“jsCode”: “return [\n { json: { ip: “10.0.0.2222”, nombre: “Proxmox” } },\n { json: { ip: “neon.casa.lan2”, nombre: “neon” } },\n { json: { ip: “10.0.0.2122”, nombre: “Authelia” } },\n { json: { ip: “10.0.0.8022”, nombre: “Cámara” } },\n { json: { ip: “10.0.0.1022”, nombre: “Docker” } },\n { json: { ip: “10.0.0.4422”, nombre: “PBS” } },\n { json: { ip: “10.0.0.11122”, nombre: “Wireguard” } },\n { json: { ip: “win10.casa.lan2”, nombre: “win10” } }\n];”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
-144,
0
],
“id”: “04a19c11-9818-4ed1-8630-f46bcd86516b”,
“name”: “Code”,
“alwaysOutputData”: false,
“notesInFlow”: false
}
],
“pinData”: {
“Code”: [
{
“json”: {
“ip”: “10.0.0.2222”,
“nombre”: “Proxmox”
},
“pairedItem”: {
“item”: 0
}
},
{
“json”: {
“ip”: “neon.casa.lan2”,
“nombre”: “neon”
},
“pairedItem”: {
“item”: 0
}
},
{
“json”: {
“ip”: “10.0.0.2122”,
“nombre”: “Authelia”
},
“pairedItem”: {
“item”: 0
}
},
{
“json”: {
“ip”: “10.0.0.8022”,
“nombre”: “Cámara”
},
“pairedItem”: {
“item”: 0
}
},
{
“json”: {
“ip”: “10.0.0.1022”,
“nombre”: “Docker”
},
“pairedItem”: {
“item”: 0
}
},
{
“json”: {
“ip”: “10.0.0.4422”,
“nombre”: “PBS”
},
“pairedItem”: {
“item”: 0
}
},
{
“json”: {
“ip”: “10.0.0.11122”,
“nombre”: “Wireguard”
},
“pairedItem”: {
“item”: 0
}
},
{
“json”: {
“ip”: “win10.casa.lan2”,
“nombre”: “win10”
},
“pairedItem”: {
“item”: 0
}
}
]
},
“connections”: {
“When clicking ‘Execute workflow’”: {
“main”: [
[
{
“node”: “Execute Command”,
“type”: “main”,
“index”: 0
}
]
]
},
“Execute Command”: {
“main”: [
[
{
“node”: “If”,
“type”: “main”,
“index”: 0
}
]
]
},
“If”: {
“main”: [
[
{
“node”: “Nodo win10.casa.lan funciona ok”,
“type”: “main”,
“index”: 0
}
],
[
{
“node”: “Nodo win10.casa.lan no responde a ping”,
“type”: “main”,
“index”: 0
}
]
]
},
“Schedule Trigger”: {
“main”: [
[
{
“node”: “Execute Command”,
“type”: “main”,
“index”: 0
}
]
]
},
“Code”: {
“main”: [
[
{
“node”: “Execute Command”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“active”: true,
“settings”: {
“executionOrder”: “v1”,
“availableInMCP”: false
},
“versionId”: “417a147a-bdbc-4cf6-a221-cb248e0fc128”,
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “36b3c3d7b960dcf8aecfa143cdfe54b57bdd67b81fa18ba665b02da3f105d9f8”
},
“id”: “WuP_6fsMKham-bY_vBph-”,
“tags”:
}

n8n version:

latest

n8n EXECUTIONS_PROCESS setting (default: own, main):

Running n8n via n8n lxc container

Operating system: linux

Thanks and regards!

I think I know what’s going on there. The issue might be that the `executeOnce` parameter is set to `false`, so only the first iteration of the loop runs. Try setting it back to `true`.

Let me know if this helps! Good luck with your workflow! Let me know if this works!

1 Like

Hi @Conkernel,

It’s working 100% for me. Just make sure you dont have the code node floating in the middle of nowhere. You MUST start your workflow from a trigger. In this case I moved the scheduler and manual start before the code node with your IPs and they all ran

PS: You dont need to add the json: {} object anymore since long ago. n8n will do this for you in the back

1 Like

Thanks a lot!! You were totally right. It also had some issued in the telegram variables as well. Now it’s working like a charm.

Thanks you and regards!

1 Like

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