Receiving 504 on execution endpoint in N8N with postgresDB

Describe the problem/error/question

Receiving 504 error for the following endpoints:


On inspecting the DB debug logs, I see the following query being made but the waitTill column in DB is always null.

query: SELECT "ExecutionEntity"."id" AS "ExecutionEntity_id", "ExecutionEntity"."waitTill" AS "ExecutionEntity_waitTill" FROM "public"."execution_entity" "ExecutionEntity" WHERE ("ExecutionEntity"."waitTill" <= $1 AND "ExecutionEntity"."status" != $2) ORDER BY "ExecutionEntity_waitTill" ASC -- PARAMETERS: ["2023-07-20T04:46:03.942Z","crashed"]

I tested the version 0.233.1 with mysql and it worked without any issues.

What is the error message (if any)?

504 (Gateway timeout)

Information on your n8n setup

  • n8n version: 0.233.1 & 1.0.3 (Tested with multiple versions)
  • Database (default: SQLite): postgresDB
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker / Kubernetes

Hi @varun_agarwal, welcome to the community.

I am sorry you’re having trouble. A waitTill value of null is expected unless you have executions in a waiting state.

Is there a chance you are using n8n behind a reverse proxy or load balancer which is returning the 504 status here (because n8n itself responds too slowly)?

Perhaps you can take a look into your n8n server logs and see there are any slow query warnings? If so, you might need to prune old executions to improve the performance when querying executions.

You might also want to look at configuring the request timeout in your reverse proxy server depending on how quickly it throws the 504 responses.

1 Like

Thanks for the quick reply @MutedJam.
I thought so too, I ran the same in a new DB and still facing the same issue.

In this case I suspect the issue is outside of n8n. The 504 error is most likely coming from a component sitting between n8n and your browser, like the aforementioned reverse proxy.

To rule this out, perhaps you can try running your n8n setup locally and access it from the same machine via localhost (rather than routing traffic through your network)?

Just tried the same. SSH’d into the pod and ran the following query:

fetch("http://localhost:5678/rest/executions-current?filter=%7B%22workflowId%22:%22snZpAHEEVihtOzGx%22%7D", {
  "headers": {
    "accept": "application/json, text/plain, */*",
    "sessionid": "", //Copy the sessionid from any of the request from the editor
    "cookie": "",  //Copy the cookies from any of the request from the editor
  "method": "GET"
}).then(x => {console.log(x.status);return x.text()}).then(x => console.log(x));

And which response did you see? Any is there any change when using an empty filter http://localhost:5678/rest/executions-current?filter=%7B%7D?

Testing this on my side using curl would return an empty array pretty much instantly when there are no executions in the database:

1 Like

Okay, I think I figured it out. It had to do with the queue I was using. I have enabled regular execution mode for now while I debug the issue with my redis provider.

Thanks @MutedJam for the quick response and support.


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