#38964·n8n

n8n VM engine got lot of error "timeout when trying to connect"

Author: kent-1Created Sep 17, 2026Updated Sep 17, 2026
Labelsteam:catsstatus:in-linearstatus:team-assigned

Bug Description

Hello,

We updated our n8n instance from 1.30.3 to 1.39.5, but after the update, we started getting a lot of "timeout when trying to connect" errors. This was especially frequent on our webhook workflows (likely because they are our most heavily requested ones).

We tried several things and finally set the following environment variable: - N8N_EXPRESSION_ENGINE=legacy. Since doing this, no more errors have occurred on version 1.39.5.

My question is: why does this happen with the v2 (VM) engine but not with the legacy one? From what I understand, the VM engine executes expressions in an isolated context, but the workload remains the exact same. If there are no errors with the legacy engine, I don't really understand why the VM engine is failing under the same workload. Any insights?

To Reproduce

n8n 2.39.5 vm engine (not legacy) heavy workload

our setup : 4 servers with 10 workers on each server (so 40 workers totally)

On last 7 days we have 1 300 000 executions :

Postgres metrics :

Expected behavior

No error like in legacy

Debug Info

2026-09-17T06:47:20.618Z | error | Worker errored while running execution 433401604 (job 57256982) {"scopes":["scaling"],"error":{"name":"Error","message":"timeout exceeded when trying to connect","stack":"Error: timeout exceeded when trying to connect\n at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected][email protected][email protected]_/node_modules/pg-pool/index.js:45:11\n at runNextTicks (node:internal/process/task_queues:65:5)\n at processTimers (node:internal/timers:615:9)\n at PostgresDriver.obtainMasterConnection (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+typeorm@file++++home+runner+_work+n8n+n8n+packages+@n8n+typeorm/node_modules/@n8n/typeorm/dist/driver/postgres/PostgresDriver.js:870:28)\n at DbConnectionMonitor.timeAcquisition (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+db@file++++home+runner+_work+n8n+n8n+packages+@n8n+db/node_modules/@n8n/db/src/connection/db-connection-monitor.ts:574:25)\n at DbConnectionMonitor.acquireConnection (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+db@file++++home+runner+_work+n8n+n8n+packages+@n8n+db/node_modules/@n8n/db/src/connection/db-connection-monitor.ts:550:11)\n at PostgresDriver.driver.obtainMasterConnection (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+db@file++++home+runner+_work+n8n+n8n+packages+@n8n+db/node_modules/@n8n/db/src/connection/db-connection-monitor.ts:538:47)\n at PostgresQueryRunner.query (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+typeorm@file++++home+runner+_work+n8n+n8n+packages+@n8n+typeorm/node_modules/@n8n/typeorm/dist/driver/postgres/PostgresQueryRunner.js:178:36)\n at PostgresQueryRunner.startTransaction (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+typeorm@file++++home+runner+_work+n8n+n8n+packages+@n8n+typeorm/node_modules/@n8n/typeorm/dist/driver/postgres/PostgresQueryRunner.js:123:13)\n at EntityManager.transaction (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+typeorm@file++++home+runner+_work+n8n+n8n+packages+@n8n+typeorm/node_modules/@n8n/typeorm/dist/entity-manager/EntityManager.js:69:13)"},"executionId":"433401604","jobId":"57256982","file":"scaling.service.js","function":"reportJobProcessingError"}

Operating System

Redhat 8

n8n Version

2.39.5

Node.js Version

26.8.2

Database

PostgreSQL

Execution mode

queue

Hosting

self hosted