Authorization is required when checking if existing flows are running

Hello, I used the solution there provided by @jan to check if other flows are running. However I’m getting this error. Authorization is required! All of my other internal http request node work fine for starting flows, so I’m unsure what the issue is.


{
"status": "rejected",
"reason": {
"name": "StatusCodeError",
"statusCode": 401,
"message": "401 - {"code":401,"message":"Authorization is required!"}",
"error": {
"code": 401,
"message": "Authorization is required!"
},
"options": {
"timeout": 3600000,
"headers": {...}, // 1 keys
"method": "GET",
"uri": "http://localhost:5678/rest/executions-current",
"gzip": true,
"rejectUnauthorized": true,
"json": true,
"simple": true,
"resolveWithFullResponse": false,
"transform2xxOnly": false
},
"response": {
"statusCode": 401,
"body": {...}, // 2 keys
"headers": {...}, // 7 keys
"request": {...} // 3 keys
}
}
}

My first guess is that you’d have basic auth configured for n8n so it’s expecting a username and password. Have you tried adding these to the HTTP Request node (under AuthenticationBasic Auth and then Credential for Basic AuthCreate New)?

1 Like

It worked. Thanks.

1 Like

But it seems I have another issue now. I added to the flow “1. Clean Up (Search)” but as you can see in the screenshot, it triggered even though 2 other flows were already running.


The example you have shared would only check if the current workflow is already executing more than once, if I see that correctly.

Based on your screenshot I understand however you want to check whether any other workflow is running? If so, you wouldn’t need to filter for the current workflow ID. You could just check whether there are more than 1 workflows running in total. Simply remove the filter part .filter(execution => execution.workflowId.toString() === $workflow.id.toString()) from your Function.

Awesome. Thanks for the quick response. That worked!

1 Like

One last question. This flow doesn’t detect if a workflow is active but in “wait” status. Can you help me with that?

So from quickly trying this out I can confirm the endpoint you are using does not return any workflows in Waiting status if that’s what you were looking at.

To find these, you could use the http://localhost:5678/rest/executions endpoint which is used when opening the executions list from the left sidebar:
image

This example workflow would find waiting workflows when testing this:

Example Workflow

image

1 Like

Unfortunately this isn’t working for me. I have 2 waiting executions however no executions are detected as waiting. I’ve noticed that in the executions model waiting executions don’t show when “any status” is selected, only when the “waiting” filter is selected. Maybe there is an additional parameter that is needed in the url as well.

After a version update, the waiting flows are now detected.

1 Like