N8n REST Socket Hang Up Issues

Hi,

I’m using /executions-current REST endpoint of n8n due to prevent concurrent executions of workflows when deployed multiple workers. I’ve faced the below issue so many times on both Auth and Get Executions nodes.

Note: I’m using this authentication workaround because user management is enabled.
Note 2: It would be great to have a setting in workflows for preventing concurrent executions. (You may convert the category of this topic from ‘Question’ to ‘Feature Request’ or I can create a new topic.)

Error Message

ERROR: UNKNOWN ERROR - check the detailed error for more information

socket hang up

{"status":"rejected","reason":{"message":"socket hang up","name":"Error","stack":"Error: socket hang up\n    at connResetException (node:internal/errors:691:14)\n    at Socket.socketOnEnd (node:_http_client:466:23)\n    at Socket.emit (node:events:538:35)\n    at Socket.emit (node:domain:475:12)\n    at endReadableNT (node:internal/streams/readable:1345:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)","code":"ECONNRESET"}}

NodeApiError: UNKNOWN ERROR - check the detailed error for more information
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/HttpRequest.node.js:894:27)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:451:47

Workflow

Output returned by the last node

n8n Setup

  • n8n version: 0.171.1
  • Database you’re using: MySQL & Redis
  • Running n8n with the execution process: own
  • Running n8n via: Docker

Hey @samaritan, I am sorry to hear you’re having trouble here. socket hang up would indicate the server closed the connection but I can’t see that happening when testing on my end.

Which {{endpoint}} value are you using? Is it a simple localhost:5678 or similar (so the instance docker container talking to itself) or is the request routed through your network?

Hi,

Endpoint is internal private IP. Like http://10.1.0.133:5678

By the way, I’m getting responses from this endpoint, just sometimes so many times this error is thrown.

Thanks a lot.

Hi,

I have an update with the issue. I have 4 workflows that each one has 30 seconds interval trigger. I’ve added one more worker, socket hang up error became rarer. When I’ve discovered that, I’ve added one more worker. Today, I faced with this error only once. I’m assuming that this error happens when the load is high on main n8n. What would your comment be? Is there any option to prevent n8n for running processes on main n8n?

Thanks!

Hm, seeing this depends on the load I think it might be worth summoning @krynble here who would be the resident experts on all things scaling n8n. I am unfortunately out of my depth here.

Hey @samaritan

In fact when n8n is under heavy load the main process might become unresponsive especially if you’re calling the executions-current endpoint multiple times, since when running in queue modes it must:

  1. Connect to queue system to check current executions
  2. Cross that with your user ID to check what are your permissions
  3. Get the execution data from database
  4. Return this to you

This ends up being very heavy and unfortunately there is no way to scale the main process but there is still hope.

There is a topic with a similar request that was solved using a Redis instance to act as a semaphore. You can find out more about this here: Deny simultaneously workflow execution / Don't execute if workflow is running

I believe this might help you.

2 Likes