Problem executing JavaScript code

It’s been a while since the new version 2.0 or later of n8n. I can no longer run any JavaScript code in my Workflows. I don’t know if it’s a bug or an error in my infrastructure!

VPS hosting.

n8n auto-warming.

n8n installed on Portainer.

n8n version 2.11.3
Below is my stack that I’m using!

my stack:

version: "3.8"

# n8n v2.x - Queue Mode + Task Runners Externos (EXEMPLO OFICIAL)
## Obs: Até esta data o recurso de TASK RUNNERS não estava funcionando na versão 2.0.3

services:
  n8n_editor:
    image: n8nio/n8n:2.11.4
    
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_PORT: ${POSTGRES_PORT:-5432}
      DB_POSTGRESDB_HOST: ${POSTGRES_HOST:-postgres}
      DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n_fila}
      DB_POSTGRESDB_USER: ${POSTGRES_USER:-postgres}
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      
      N8N_HOST: ${N8N_DOMAIN}
      N8N_EDITOR_BASE_URL: https://${N8N_DOMAIN}
      N8N_PROTOCOL: ${N8N_PROTOCOL:-https}
      NODE_ENV: production
      WEBHOOK_URL: https://${N8N_WEBHOOK_DOMAIN}
      
      EXECUTIONS_MODE: queue
      QUEUE_BULL_REDIS_HOST: ${REDIS_HOST:-redis}
      QUEUE_BULL_REDIS_PORT: ${REDIS_PORT:-6379}
      QUEUE_BULL_REDIS_DB: ${REDIS_DB:-2}
      
      # Task Runners EXTERNOS (exemplo oficial)
      #N8N_RUNNERS_ENABLED: 'true'
      N8N_RUNNERS_MODE: 'external'
      N8N_RUNNERS_BROKER_LISTEN_ADDRESS: 0.0.0.0
      N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
      N8N_PROXY_HOPS: 1
      OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS: 'true'
      
      NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL:-moment,lodash}
      N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE: 'true'
      N8N_REINSTALL_MISSING_PACKAGES: 'true'
      
      EXECUTIONS_DATA_PRUNE: ${EXECUTIONS_DATA_PRUNE:-true}
      EXECUTIONS_DATA_MAX_AGE: ${EXECUTIONS_DATA_MAX_AGE:-336}
      
      N8N_BLOCK_ENV_ACCESS_IN_NODE: ${N8N_BLOCK_ENV_ACCESS_IN_NODE:-'true'}
      N8N_RESTRICT_FILE_ACCESS_TO: ${N8N_RESTRICT_FILE_ACCESS_TO:-/home/node/.n8n-files}
      N8N_DEFAULT_BINARY_DATA_MODE: ${N8N_DEFAULT_BINARY_DATA_MODE:-database}
      
      GENERIC_TIMEZONE: ${TIMEZONE:-America/Sao_Paulo}
      TZ: ${TIMEZONE:-America/Sao_Paulo}
      
      N8N_SKIP_AUTH_ON_OAUTH_CALLBACK: ${N8N_SKIP_AUTH_ON_OAUTH_CALLBACK:-false}
      N8N_GIT_NODE_DISABLE_BARE_REPOS: ${N8N_GIT_NODE_DISABLE_BARE_REPOS:-true}
      NODES_EXCLUDE: ${NODES_EXCLUDE:-n8n-nodes-base.executeCommand,n8n-nodes-base.localFileTrigger}

    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: '1.0'
          memory: 2048M
      labels:
        - traefik.enable=true
        - traefik.http.routers.n8n_editor.rule=Host(`${N8N_DOMAIN}`)
        - traefik.http.routers.n8n_editor.service=n8n_editor
        - traefik.http.routers.n8n_editor.entrypoints=${TRAEFIK_ENTRYPOINT:-websecure}
        - traefik.http.routers.n8n_editor.tls.certresolver=${TRAEFIK_CERT_RESOLVER:-le}
        - traefik.http.routers.n8n_editor.tls=true
        - traefik.http.services.n8n_editor.loadbalancer.server.port=5678
    
    networks:
      - traefik_public
      - digital_network

  n8n_webhook:
    image: n8nio/n8n:2.11.4
    command: webhook
    
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_PORT: ${POSTGRES_PORT:-5432}
      DB_POSTGRESDB_HOST: ${POSTGRES_HOST:-postgres}
      DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n_fila}
      DB_POSTGRESDB_USER: ${POSTGRES_USER:-postgres}
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      
      N8N_HOST: ${N8N_DOMAIN}
      N8N_EDITOR_BASE_URL: https://${N8N_DOMAIN}/
      N8N_PROTOCOL: ${N8N_PROTOCOL:-https}
      NODE_ENV: production
      WEBHOOK_URL: https://${N8N_WEBHOOK_DOMAIN}/
      
      EXECUTIONS_MODE: queue
      QUEUE_BULL_REDIS_HOST: ${REDIS_HOST:-redis}
      QUEUE_BULL_REDIS_PORT: ${REDIS_PORT:-6379}
      QUEUE_BULL_REDIS_DB: ${REDIS_DB:-2}
      
      # Task Runners EXTERNOS
      #N8N_RUNNERS_ENABLED: 'true'
      N8N_RUNNERS_MODE: 'external'
      N8N_RUNNERS_BROKER_LISTEN_ADDRESS: 0.0.0.0
      N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
      N8N_PROXY_HOPS: 1
      
      NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL:-moment,lodash}
      N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE: 'true'
      N8N_REINSTALL_MISSING_PACKAGES: 'true'
      
      EXECUTIONS_DATA_PRUNE: ${EXECUTIONS_DATA_PRUNE:-true}
      EXECUTIONS_DATA_MAX_AGE: ${EXECUTIONS_DATA_MAX_AGE:-336}
      
      N8N_LOG_LEVEL: ${N8N_LOG_LEVEL:-info}
      CODE_ENABLE_STDOUT: 'true'
      
      N8N_BLOCK_ENV_ACCESS_IN_NODE: ${N8N_BLOCK_ENV_ACCESS_IN_NODE:-'true'}
      N8N_RESTRICT_FILE_ACCESS_TO: ${N8N_RESTRICT_FILE_ACCESS_TO:-/home/node/.n8n-files}
      N8N_DEFAULT_BINARY_DATA_MODE: ${N8N_DEFAULT_BINARY_DATA_MODE:-database}
      
      GENERIC_TIMEZONE: ${TIMEZONE:-America/Sao_Paulo}
      TZ: ${TIMEZONE:-America/Sao_Paulo}
      
      N8N_SKIP_AUTH_ON_OAUTH_CALLBACK: ${N8N_SKIP_AUTH_ON_OAUTH_CALLBACK:-false}
      N8N_GIT_NODE_DISABLE_BARE_REPOS: ${N8N_GIT_NODE_DISABLE_BARE_REPOS:-true}
      NODES_EXCLUDE: ${NODES_EXCLUDE:-n8n-nodes-base.executeCommand,n8n-nodes-base.localFileTrigger}
    
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: '0.5'
          memory: 1024M
      labels:
        - traefik.enable=true
        - traefik.http.routers.n8n_webhook.rule=Host(`${N8N_WEBHOOK_DOMAIN}`)
        - traefik.http.routers.n8n_webhook.service=n8n_webhook
        - traefik.http.routers.n8n_webhook.entrypoints=${TRAEFIK_ENTRYPOINT:-websecure}
        - traefik.http.routers.n8n_webhook.tls.certresolver=${TRAEFIK_CERT_RESOLVER:-le}
        - traefik.http.routers.n8n_webhook.tls=true
        - traefik.http.services.n8n_webhook.loadbalancer.server.port=5678
    
    networks:
      - traefik_public
      - digital_network

  n8n_worker:
    image: n8nio/n8n:2.11.4
    command: worker --concurrency=5
    
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_PORT: ${POSTGRES_PORT:-5432}
      DB_POSTGRESDB_HOST: ${POSTGRES_HOST:-postgres}
      DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n_fila}
      DB_POSTGRESDB_USER: ${POSTGRES_USER:-postgres}
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      
      LANGCHAIN_ENDPOINT: ${LANGCHAIN_ENDPOINT:-https://api.smith.langchain.com}
      LANGCHAIN_TRACING_V2: ${LANGCHAIN_TRACING_V2:-"false"}
      LANGCHAIN_API_KEY: ${LANGCHAIN_API_KEY:-}
      
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      
      N8N_HOST: ${N8N_DOMAIN}
      N8N_EDITOR_BASE_URL: https://${N8N_DOMAIN}/
      N8N_PROTOCOL: ${N8N_PROTOCOL:-https}
      NODE_ENV: production
      WEBHOOK_URL: https://${N8N_WEBHOOK_DOMAIN}/
      
      EXECUTIONS_MODE: queue
      QUEUE_BULL_REDIS_HOST: ${REDIS_HOST:-redis}
      QUEUE_BULL_REDIS_PORT: ${REDIS_PORT:-6379}
      QUEUE_BULL_REDIS_DB: ${REDIS_DB:-2}
      
      # Task Runners EXTERNOS - worker expõe o broker
      #N8N_RUNNERS_ENABLED: 'true'
      N8N_RUNNERS_MODE: 'external'
      N8N_RUNNERS_BROKER_LISTEN_ADDRESS: 0.0.0.0
      N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
      N8N_PROXY_HOPS: 1
      
      NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL:-moment,lodash}
      N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE: 'true'
      N8N_REINSTALL_MISSING_PACKAGES: 'true'
      
      EXECUTIONS_DATA_PRUNE: ${EXECUTIONS_DATA_PRUNE:-true}
      EXECUTIONS_DATA_MAX_AGE: ${EXECUTIONS_DATA_MAX_AGE:-336}
      
      N8N_LOG_LEVEL: ${N8N_LOG_LEVEL:-info}
      CODE_ENABLE_STDOUT: 'true'
      
      N8N_BLOCK_ENV_ACCESS_IN_NODE: ${N8N_BLOCK_ENV_ACCESS_IN_NODE:-'true'}
      N8N_RESTRICT_FILE_ACCESS_TO: ${N8N_RESTRICT_FILE_ACCESS_TO:-/home/node/.n8n-files}
      N8N_DEFAULT_BINARY_DATA_MODE: ${N8N_DEFAULT_BINARY_DATA_MODE:-database}
      
      GENERIC_TIMEZONE: ${TIMEZONE:-America/Sao_Paulo}
      TZ: ${TIMEZONE:-America/Sao_Paulo}
      
      N8N_SKIP_AUTH_ON_OAUTH_CALLBACK: ${N8N_SKIP_AUTH_ON_OAUTH_CALLBACK:-false}
      N8N_GIT_NODE_DISABLE_BARE_REPOS: ${N8N_GIT_NODE_DISABLE_BARE_REPOS:-true}
      NODES_EXCLUDE: ${NODES_EXCLUDE:-n8n-nodes-base.executeCommand,n8n-nodes-base.localFileTrigger}
    
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: '0.5'
          memory: 1024M
    
    networks:
      - digital_network

  # Task Runners - EXATAMENTE como o exemplo oficial
  n8n_task_runners:
    image: n8nio/runners:2.11.4
    
    environment:
      # Conecta ao worker via HTTP (porta 5679)
      N8N_RUNNERS_TASK_BROKER_URI: http://n8n_n8n_worker:5679
      
      # Token de autenticação (MESMO em todos!)
      N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
      
      # Permite bibliotecas externas
      NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL:-moment,lodash}
      
      # Timezone
      GENERIC_TIMEZONE: America/Sao_Paulo
      TZ: America/Sao_Paulo
    
    depends_on:
      - n8n_worker
    
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: '1.5'
          memory: 3072M
      restart_policy:
        condition: any
        delay: 5s
    
    networks:
      - digital_network

networks:
  traefik_public:
    external: true
  digital_network:
    external: true
1 Like

Hi @John_da_Costa_Goncal Welcome!
first N8N_RUNNERS_ENABLED is commented out on all services, enable that. Let me know how it works after enabling it.

1 Like

Hi @John_da_Costa_Goncal

I think the issue is in your stack: N8N_RUNNERS_ENABLED is commented out on all your services.

Since n8n v2.0, Code nodes require the task runner. Without this flag, the broker on port 5679 never starts, so your n8nio/runners container has nothing to connect to and every Code node times out after 60s.

Uncomment it on at least your worker (since you have OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS=true), redeploy, and see if it works.

Also verify that the broker URI in your runners container matches the actual Swarm service name for your worker.

Let me know :crossed_fingers:

I’ve already done that! Before, I was using the N8N_RUNNERS_ENABLED variable with it enabled. The log always warned that the variable was deprecated. Regardless of whether the N8N_RUNNERS_ENABLED variable is enabled or not, the problem persists.

I’ve already done that! Before, I was using the N8N_RUNNERS_ENABLED variable with it enabled. The log always warned that the variable was deprecated. Regardless of whether the N8N_RUNNERS_ENABLED variable is enabled or not, the problem persists.

ok… potential issues:
If your stack isn’t named n8n, then n8n_n8n_worker won’t resolve. Check what docker service ls shows and match the URI accordingly.
There’s a community report indicating that in n8n 2.x, external task runners should connect to the main instance (editor), not the worker. The main instance acts as the task broker. Try pointing your runner to the editor instead

Can you share the output of docker service logs <your_runner_service>? That will show whether the runner is failing to connect, getting auth errors, or never reaching the broker at all.

output of the docker service ls command:

container logs n8n_n8n_task_runners:

2026/03/24 16:06:29 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:06:29 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:06:29 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:06:29 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:06:29 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:06:43 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:06:53 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:06:55 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:06:55 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:06:56 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:06:56 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:06:56 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:07:09 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:07:19 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:07:24 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:07:24 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:07:24 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:07:24 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:07:24 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:07:37 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:07:48 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:07:50 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:07:50 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:07:50 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:07:50 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:07:51 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:08:04 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:08:14 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:08:21 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:08:21 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:08:22 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:08:22 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:08:22 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:08:35 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:08:45 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:08:55 WARN [launcher:js] Found runner unresponsive (3/6)
2026/03/24 16:09:00 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:09:00 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:09:01 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:09:01 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:09:01 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:09:14 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:09:24 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:09:30 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:09:30 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:09:30 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:09:30 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:09:30 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:09:44 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:09:54 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:09:59 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:09:59 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:09:59 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:09:59 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:09:59 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:10:12 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:10:22 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:10:30 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:10:30 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:10:30 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:10:30 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:10:31 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:10:44 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:10:54 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:10:59 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:10:59 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:10:59 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:10:59 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:11:00 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:11:13 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:11:23 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:11:33 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:11:33 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:11:33 WARN [launcher:js] Found runner unresponsive (3/6)
2026/03/24 16:11:33 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:11:33 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:11:34 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:11:47 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:11:57 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:12:04 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:12:04 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:12:05 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:12:05 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:12:05 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:12:18 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:12:28 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:12:36 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:12:36 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:12:38 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:12:38 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:12:38 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:12:51 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:13:01 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:13:11 WARN [launcher:js] Found runner unresponsive (3/6)
2026/03/24 16:13:18 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:13:18 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:13:19 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:13:19 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:13:26 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:15:38 ERROR [launcher:js] Failed to execute `launch` command: failed to fetch grant token for runner: exhausted retries to fetch grant token: gave up retrying operation `grant-token-fetch` on reaching max retry time 1m0s, last error: failed to fetch grant token: Post "http://n8n_n8n_worker:5679/runners/auth": read tcp 10.0.3.93:39140->10.0.3.80:5679: read: connection reset by peer

container logs n8n_n8n_editor

Slow database query
Slow database query
Slow database query
Pruning old insights data
Database connection timed out
Error fetching feature flags DOMException [TimeoutError]: The operation was aborted due to timeout
    at new DOMException (node:internal/per_context/domexception:76:18)
    at Timeout._onTimeout (node:internal/abort_controller:154:9)
    at listOnTimeout (node:internal/timers:605:17)
    at processTimers (node:internal/timers:541:7)
Database connection timed out
Database connection recovered
Slow database query
Slow database query
Slow database query
Slow database query
Database connection timed out
Database connection recovered
User attempted to access a workflow without permissions
Failed to find workflow with ID "uciCdZiAfEhvsIX7XHKLR"
User attempted to access a workflow without permissions
Failed to find workflow with ID "ufkXe0LBgCHjnFbE"
User attempted to access a workflow without permissions
Failed to find workflow with ID "P4Jmd1irDIqA1QrO"
Database connection timed out
Database connection recovered
Slow database query
Slow database query
Slow database query
Slow database query
User attempted to access a workflow without permissions
Failed to find workflow with ID "P4Jmd1irDIqA1QrO"
Database connection timed out
Database connection recovered
User attempted to access a workflow without permissions
Failed to find workflow with ID "P4Jmd1irDIqA1QrO"
Enqueued execution 205 (job 72)
Execution 205 (job 72) finished
Database connection timed out
Database connection recovered
(node:7) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
Execution 206 (job 73) finished
Database connection timed out
Database connection recovered
User attempted to access a workflow without permissions
Failed to find workflow with ID "uciCdZiAfEhvsIX7XHKLR"
User attempted to access a workflow without permissions
Failed to find workflow with ID "ufkXe0LBgCHjnFbE"
User attempted to access a workflow without permissions
Failed to find workflow with ID "xpWLm0Qpi_Wh0M2qLT2yk"
User attempted to access a workflow without permissions
Failed to find workflow with ID "xpWLm0Qpi_Wh0M2qLT2yk"
Pruning old insights data
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Blocked GET / for "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.3; +https://openai.com/gptbot)"
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Pruning old insights data
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Pruning old insights data
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Blocked GET / for "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.3; +https://openai.com/gptbot)"
Pruning old insights data
Database connection timed out
Database connection recovered
Blocked GET /robots.txt for "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
Blocked GET /rest/oauth2-credential/callback for "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.7632.159 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
Slow database query
Slow database query
Slow database query
Slow database query
Slow database query
Slow database query
Slow database query
Slow database query
Slow database query
Slow database query
Slow database query
Slow database query
Database connection timed out
Database connection recovered
Pruning old insights data
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Error fetching feature flags Error [PostHogFetchHttpError]: HTTP error while fetching PostHog: 503
    at new PostHogFetchHttpError (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/posthog-core/src/index.ts:31:5)
    at PostHog.<anonymous> (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/posthog-core/src/index.ts:549:17)
    at step (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/node_modules/tslib/tslib.es6.js:102:23)
    at Object.next (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/node_modules/tslib/tslib.es6.js:83:53)
    at fulfilled (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/node_modules/tslib/tslib.es6.js:73:58)
    at processTicksAndRejections (node:internal/process/task_queues:103:5) {
  response: Response {}
}
Enqueued execution 208 (job 75)
Execution 208 (job 75) finished

container logs n8n_n8n_webhook:

[license SDK] Skipping renewal on init: license cert is not due for renewal
Version: 2.11.4
Webhook listener waiting for requests.
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Database connection timed out
Database connection recovered
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Blocked GET / for "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.3; +https://openai.com/gptbot)"
Execution 187 (job 42) finished
Database connection timed out
Database connection recovered
Execution 189 (job 44) finished
Execution 189 (job 45) finished
Execution 190 (job 46) finished
Execution 190 (job 47) finished
Execution 191 (job 48) finished
Execution 191 (job 49) finished
Execution 192 (job 50) finished
Execution 192 (job 51) finished
Execution 193 (job 52) finished
Execution 193 (job 53) finished
Execution 194 (job 54) finished
Execution 194 (job 55) finished
Execution 195 (job 56) finished
Execution 195 (job 57) finished
Execution 196 (job 58) finished
Execution 196 (job 59) finished
Execution 197 (job 60) finished
Execution 197 (job 61) finished
Execution 198 (job 62) finished
Execution 199 (job 63) finished
Execution 200 (job 64) finished
Execution 201 (job 65) finished
Execution 202 (job 66) finished
Execution 202 (job 67) finished
Execution 203 (job 68) finished
Execution 203 (job 69) finished
Execution 204 (job 70) finished
Execution 204 (job 71) finished
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
[license SDK] Skipping renewal on init: renewOnInit is disabled in config
[license SDK] Skipping renewal on init: autoRenewEnabled is disabled in config
[license SDK] Skipping renewal on init: license cert is not due for renewal
Execution 205 (job 72) finished
Database connection timed out
Database connection timed out
(node:7) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error in handling webhook request POST /webhook/089a1a36-18c9-4fdf-adec-41a3870e97e6: There was a problem executing the workflow
Database connection recovered
Enqueued execution 206 (job 73)
Execution 206 (job 73) finished
Database connection timed out
Database connection recovered
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Blocked GET / for "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.3; +https://openai.com/gptbot)"
Database connection timed out
Database connection recovered
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Blocked GET / for "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.3; +https://openai.com/gptbot)"
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Error in handling webhook request POST /webhook/58a27233-8999-4671-a53d-87124e5082d8: There was a problem executing the workflow
Error in handling webhook request POST /webhook/58a27233-8999-4671-a53d-87124e5082d8: There was a problem executing the workflow
Enqueued execution 207 (job 74)
Problem with execution 207: This execution failed to be processed too many times and will no longer retry. To allow this execution to complete, please break down your workflow or scale up your workers or adjust your worker settings.. Aborting.
This execution failed to be processed too many times and will no longer retry. To allow this execution to complete, please break down your workflow or scale up your workers or adjust your worker settings. (execution 207)
Error: job stalled more than maxStalledCount (execution 207)
Execution 208 (job 75) finished

container logs n8n_n8n_worker:

Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (b5b9b191b5ce14d0) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (f4d52b5f98ad9155) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (f5ad4fc912872129) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (55ac62a194c59a4b) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (137ecff7ca8d1b28) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (718364a71704555d) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (265bccd0ece31370) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (6642cf8964eb0a33) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (b31d6dc98d774d90) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (50f478ba28c7dcf5) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (546bec97b39c1a26) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (9ebea7b922024c44) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (a77b473790198ffc) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (3e089e52e0440df1) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (5547490735e79ee2) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (a5af74a5c591c8b8) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (e4cfe2317b2c4b6f) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (7b0a149ee8d4aef6) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (25ae09e2c4c9776c) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (ba63318120f12541) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (72df753bfa99abb4) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (a909b53d1aae01ea) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (956d41c28711501e) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (fd7ec64010d84ba5) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (090be9f397a4f1c4) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (33136bd5a3c0d80a) 
Task runner connection attempt failed: invalid or expired grant token
Registered runner "launcher-javascript" (3e988e9d9f64a4b1) 
Task runner connection attempt failed: invalid or expired grant token
Worker started execution 207 (job 74)
Database connection timed out
Registered runner "launcher-javascript" (a1aa9920814ba683) 
Runner (a1aa9920814ba683) took too long to acknowledge acceptance of task (t_GvruE1)
Database connection recovered
Task request timed out
Error: Task request timed out
    at ErrorReporter.wrap (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@opentelemetry+exporter-trace-otlp_9f358c3eeaef0d2736f54ac9757ada43/node_modules/n8n-core/src/errors/error-reporter.ts:308:37)
    at ErrorReporter.error (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@opentelemetry+exporter-trace-otlp_9f358c3eeaef0d2736f54ac9757ada43/node_modules/n8n-core/src/errors/error-reporter.ts:294:25)
    at LocalTaskRequester.requestExpired (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:309:22)
    at LocalTaskRequester.onMessage (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:272:10)
    at TaskBroker.handleRequestTimeout (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:120:50)
    at Timeout.<anonymous> (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:107:9)
    at listOnTimeout (node:internal/timers:605:17)
    at processTimers (node:internal/timers:541:7)
Task request timed out after 60 seconds
Worker finished execution 207 (job 74)
Worker errored while running execution 207 (job 74)
Queue errored
Queue errored
Error: Missing key for job 74 failed
    at Object.finishedErrors (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]_patch_hash=a4b6d56db16fe5870646929938466d6a5c668435fd1551bed6a93fffb597ba42/node_modules/bull/lib/scripts.js:287:16)
    at Job.moveToFailed (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]_patch_hash=a4b6d56db16fe5870646929938466d6a5c668435fd1551bed6a93fffb597ba42/node_modules/bull/lib/job.js:345:19)
    at processTicksAndRejections (node:internal/process/task_queues:103:5)
Database connection timed out
Database connection recovered
Database connection timed out
Database connection recovered
Worker started execution 208 (job 75)
Database connection timed out
Database connection recovered
Task request timed out
Error: Task request timed out
    at ErrorReporter.wrap (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@opentelemetry+exporter-trace-otlp_9f358c3eeaef0d2736f54ac9757ada43/node_modules/n8n-core/src/errors/error-reporter.ts:308:37)
    at ErrorReporter.error (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@opentelemetry+exporter-trace-otlp_9f358c3eeaef0d2736f54ac9757ada43/node_modules/n8n-core/src/errors/error-reporter.ts:294:25)
    at LocalTaskRequester.requestExpired (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:309:22)
    at LocalTaskRequester.onMessage (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:272:10)
    at TaskBroker.handleRequestTimeout (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:120:50)
    at Timeout.<anonymous> (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:107:9)
    at listOnTimeout (node:internal/timers:605:17)
    at processTimers (node:internal/timers:541:7)
Task request timed out after 60 seconds
Worker finished execution 208 (job 75)

the runner is getting 403s because N8N_RUNNERS_AUTH_TOKEN isn’t resolving to the same value on both the worker and runner containers. Swarm sometimes silently fails to inject env vars. fix that first. the database timeouts are a separate issue but also need attention since Postgres is clearly being starved for resources.​​​​​​​​​​​​​​​​

The only thing i personally see that needs attention is your worker is set to 0.5 CPU / 1GB RAM, that’s too low to handle both executions and the task broker. Combined with your constant database timeouts, the grant token exchange can’t complete in time.

try these:
Increase your worker resources to at least 1.0 CPU / 2048M memory

Check your Postgres container resources, every service is logging “Database connection timed out” nonstop, which slows everything down. Consider reducing EXECUTIONS_DATA_MAX_AGE from 336 to 72 to lighten the DB load

Redeploy

This community user who had this exact issue confirmed that allocating more resources resolved it immediately. check the thread below

Here’s the image!

I’ll try it and then come back and let you know if it worked!

1 Like

Unfortunately, the problem still persists.

Setting up environment variables.

Here is the corrected stack.

version: "3.8"

# n8n v2.x - Queue Mode + Task Runners Externos (EXEMPLO OFICIAL)
## Obs: Até esta data o recurso de TASK RUNNERS não estava funcionando na versão 2.0.3

services:
  n8n_editor:
    image: n8nio/n8n:2.11.4
    
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_PORT: ${POSTGRES_PORT:-5432}
      DB_POSTGRESDB_HOST: ${POSTGRES_HOST:-postgres}
      DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n_fila}
      DB_POSTGRESDB_USER: ${POSTGRES_USER:-postgres}
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      
      N8N_HOST: ${N8N_DOMAIN}
      N8N_EDITOR_BASE_URL: https://${N8N_DOMAIN}
      N8N_PROTOCOL: ${N8N_PROTOCOL:-https}
      NODE_ENV: production
      WEBHOOK_URL: https://${N8N_WEBHOOK_DOMAIN}
      
      EXECUTIONS_MODE: queue
      QUEUE_BULL_REDIS_HOST: ${REDIS_HOST:-redis}
      QUEUE_BULL_REDIS_PORT: ${REDIS_PORT:-6379}
      QUEUE_BULL_REDIS_DB: ${REDIS_DB:-2}
      
      # Task Runners EXTERNOS (exemplo oficial)
      #N8N_RUNNERS_ENABLED: 'true'
      N8N_RUNNERS_MODE: 'external'
      N8N_RUNNERS_BROKER_LISTEN_ADDRESS: 0.0.0.0
      N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
      N8N_PROXY_HOPS: 1
      OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS: 'true'
      
      NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL:-moment,lodash}
      N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE: 'true'
      N8N_REINSTALL_MISSING_PACKAGES: 'true'
      
      EXECUTIONS_DATA_PRUNE: ${EXECUTIONS_DATA_PRUNE:-true}
      EXECUTIONS_DATA_MAX_AGE: ${EXECUTIONS_DATA_MAX_AGE:-72}
      
      N8N_BLOCK_ENV_ACCESS_IN_NODE: ${N8N_BLOCK_ENV_ACCESS_IN_NODE:-'true'}
      N8N_RESTRICT_FILE_ACCESS_TO: ${N8N_RESTRICT_FILE_ACCESS_TO:-/home/node/.n8n-files}
      N8N_DEFAULT_BINARY_DATA_MODE: ${N8N_DEFAULT_BINARY_DATA_MODE:-database}
      
      GENERIC_TIMEZONE: ${TIMEZONE:-America/Sao_Paulo}
      TZ: ${TIMEZONE:-America/Sao_Paulo}
      
      N8N_SKIP_AUTH_ON_OAUTH_CALLBACK: ${N8N_SKIP_AUTH_ON_OAUTH_CALLBACK:-false}
      N8N_GIT_NODE_DISABLE_BARE_REPOS: ${N8N_GIT_NODE_DISABLE_BARE_REPOS:-true}
      NODES_EXCLUDE: ${NODES_EXCLUDE:-n8n-nodes-base.executeCommand,n8n-nodes-base.localFileTrigger}

    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: '1.0'
          memory: 2048M
      labels:
        - traefik.enable=true
        - traefik.http.routers.n8n_editor.rule=Host(`${N8N_DOMAIN}`)
        - traefik.http.routers.n8n_editor.service=n8n_editor
        - traefik.http.routers.n8n_editor.entrypoints=${TRAEFIK_ENTRYPOINT:-websecure}
        - traefik.http.routers.n8n_editor.tls.certresolver=${TRAEFIK_CERT_RESOLVER:-le}
        - traefik.http.routers.n8n_editor.tls=true
        - traefik.http.services.n8n_editor.loadbalancer.server.port=5678
    
    networks:
      - traefik_public
      - digital_network

  n8n_webhook:
    image: n8nio/n8n:2.11.4
    command: webhook
    
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_PORT: ${POSTGRES_PORT:-5432}
      DB_POSTGRESDB_HOST: ${POSTGRES_HOST:-postgres}
      DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n_fila}
      DB_POSTGRESDB_USER: ${POSTGRES_USER:-postgres}
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      
      N8N_HOST: ${N8N_DOMAIN}
      N8N_EDITOR_BASE_URL: https://${N8N_DOMAIN}/
      N8N_PROTOCOL: ${N8N_PROTOCOL:-https}
      NODE_ENV: production
      WEBHOOK_URL: https://${N8N_WEBHOOK_DOMAIN}/
      
      EXECUTIONS_MODE: queue
      QUEUE_BULL_REDIS_HOST: ${REDIS_HOST:-redis}
      QUEUE_BULL_REDIS_PORT: ${REDIS_PORT:-6379}
      QUEUE_BULL_REDIS_DB: ${REDIS_DB:-2}
      
      # Task Runners EXTERNOS
      #N8N_RUNNERS_ENABLED: 'true'
      N8N_RUNNERS_MODE: 'external'
      N8N_RUNNERS_BROKER_LISTEN_ADDRESS: 0.0.0.0
      N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
      N8N_PROXY_HOPS: 1
      
      NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL:-moment,lodash}
      N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE: 'true'
      N8N_REINSTALL_MISSING_PACKAGES: 'true'
      
      EXECUTIONS_DATA_PRUNE: ${EXECUTIONS_DATA_PRUNE:-true}
      EXECUTIONS_DATA_MAX_AGE: ${EXECUTIONS_DATA_MAX_AGE:-72}
      
      N8N_LOG_LEVEL: ${N8N_LOG_LEVEL:-info}
      CODE_ENABLE_STDOUT: 'true'
      
      N8N_BLOCK_ENV_ACCESS_IN_NODE: ${N8N_BLOCK_ENV_ACCESS_IN_NODE:-'true'}
      N8N_RESTRICT_FILE_ACCESS_TO: ${N8N_RESTRICT_FILE_ACCESS_TO:-/home/node/.n8n-files}
      N8N_DEFAULT_BINARY_DATA_MODE: ${N8N_DEFAULT_BINARY_DATA_MODE:-database}
      
      GENERIC_TIMEZONE: ${TIMEZONE:-America/Sao_Paulo}
      TZ: ${TIMEZONE:-America/Sao_Paulo}
      
      N8N_SKIP_AUTH_ON_OAUTH_CALLBACK: ${N8N_SKIP_AUTH_ON_OAUTH_CALLBACK:-false}
      N8N_GIT_NODE_DISABLE_BARE_REPOS: ${N8N_GIT_NODE_DISABLE_BARE_REPOS:-true}
      NODES_EXCLUDE: ${NODES_EXCLUDE:-n8n-nodes-base.executeCommand,n8n-nodes-base.localFileTrigger}
    
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: '1.0'
          memory: 2048M
      labels:
        - traefik.enable=true
        - traefik.http.routers.n8n_webhook.rule=Host(`${N8N_WEBHOOK_DOMAIN}`)
        - traefik.http.routers.n8n_webhook.service=n8n_webhook
        - traefik.http.routers.n8n_webhook.entrypoints=${TRAEFIK_ENTRYPOINT:-websecure}
        - traefik.http.routers.n8n_webhook.tls.certresolver=${TRAEFIK_CERT_RESOLVER:-le}
        - traefik.http.routers.n8n_webhook.tls=true
        - traefik.http.services.n8n_webhook.loadbalancer.server.port=5678
    
    networks:
      - traefik_public
      - digital_network

  n8n_worker:
    image: n8nio/n8n:2.11.4
    command: worker --concurrency=5
    
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_PORT: ${POSTGRES_PORT:-5432}
      DB_POSTGRESDB_HOST: ${POSTGRES_HOST:-postgres}
      DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n_fila}
      DB_POSTGRESDB_USER: ${POSTGRES_USER:-postgres}
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      
      LANGCHAIN_ENDPOINT: ${LANGCHAIN_ENDPOINT:-https://api.smith.langchain.com}
      LANGCHAIN_TRACING_V2: ${LANGCHAIN_TRACING_V2:-"false"}
      LANGCHAIN_API_KEY: ${LANGCHAIN_API_KEY:-}
      
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      
      N8N_HOST: ${N8N_DOMAIN}
      N8N_EDITOR_BASE_URL: https://${N8N_DOMAIN}/
      N8N_PROTOCOL: ${N8N_PROTOCOL:-https}
      NODE_ENV: production
      WEBHOOK_URL: https://${N8N_WEBHOOK_DOMAIN}/
      
      EXECUTIONS_MODE: queue
      QUEUE_BULL_REDIS_HOST: ${REDIS_HOST:-redis}
      QUEUE_BULL_REDIS_PORT: ${REDIS_PORT:-6379}
      QUEUE_BULL_REDIS_DB: ${REDIS_DB:-2}
      
      # Task Runners EXTERNOS - worker expõe o broker
      #N8N_RUNNERS_ENABLED: 'true'
      N8N_RUNNERS_MODE: 'external'
      N8N_RUNNERS_BROKER_LISTEN_ADDRESS: 0.0.0.0
      N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
      N8N_PROXY_HOPS: 1
      
      NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL:-moment,lodash}
      N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE: 'true'
      N8N_REINSTALL_MISSING_PACKAGES: 'true'
      
      EXECUTIONS_DATA_PRUNE: ${EXECUTIONS_DATA_PRUNE:-true}
      EXECUTIONS_DATA_MAX_AGE: ${EXECUTIONS_DATA_MAX_AGE:-72}
      
      N8N_LOG_LEVEL: ${N8N_LOG_LEVEL:-info}
      CODE_ENABLE_STDOUT: 'true'
      
      N8N_BLOCK_ENV_ACCESS_IN_NODE: ${N8N_BLOCK_ENV_ACCESS_IN_NODE:-'true'}
      N8N_RESTRICT_FILE_ACCESS_TO: ${N8N_RESTRICT_FILE_ACCESS_TO:-/home/node/.n8n-files}
      N8N_DEFAULT_BINARY_DATA_MODE: ${N8N_DEFAULT_BINARY_DATA_MODE:-database}
      
      GENERIC_TIMEZONE: ${TIMEZONE:-America/Sao_Paulo}
      TZ: ${TIMEZONE:-America/Sao_Paulo}
      
      N8N_SKIP_AUTH_ON_OAUTH_CALLBACK: ${N8N_SKIP_AUTH_ON_OAUTH_CALLBACK:-false}
      N8N_GIT_NODE_DISABLE_BARE_REPOS: ${N8N_GIT_NODE_DISABLE_BARE_REPOS:-true}
      NODES_EXCLUDE: ${NODES_EXCLUDE:-n8n-nodes-base.executeCommand,n8n-nodes-base.localFileTrigger}
    
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: '1.0'
          memory: 2048M
    
    networks:
      - digital_network

  # Task Runners - EXATAMENTE como o exemplo oficial
  n8n_task_runners:
    image: n8nio/runners:2.11.4
    
    environment:
      # Conecta ao worker via HTTP (porta 5679)
      N8N_RUNNERS_TASK_BROKER_URI: http://n8n_n8n_worker:5679
      
      # Token de autenticação (MESMO em todos!)
      N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
      
      # Permite bibliotecas externas
      NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL:-moment,lodash}
      
      # Timezone
      GENERIC_TIMEZONE: America/Sao_Paulo
      TZ: America/Sao_Paulo
    
    depends_on:
      - n8n_worker
    
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: '1.5'
          memory: 3072M
      restart_policy:
        condition: any
        delay: 5s
    
    networks:
      - digital_network

networks:
  traefik_public:
    external: true
  digital_network:
    external: true

container logs n8n_n8n_editor:

Initializing n8n process
n8n ready on ::, port 5678
n8n Task Broker ready on 0.0.0.0, port 5679
[license SDK] Skipping renewal on init: license cert is not due for renewal
Database connection timed out
Database connection timed out
Database connection timed out
Database connection timed out
Database connection timed out
Database connection recovered
Version: 2.11.4
Building workflow dependency index...
Start Active Workflows:
Database connection timed out
Database connection recovered
Activated workflow "mcp-server-AgendamentoV4" (ID: tAhtJpoXRZ1XKCAm1mzR6)
(node:7) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Activated workflow "ToolsCustomerNewAgendamento" (ID: jBDhVEUa1aL_RW9sirDvZ)
Finished building workflow dependency index. Processed 9 draft workflows, 0 published workflows.
Activated workflow "mcp_server_new_google_calendario" (ID: OVjHSoOZvidw_vWb4x2gu)
Activated workflow "EvolutionAPI-New-AgendamentoFollowUp-MCP-supabase-Elevenlabs-001" (ID: FcDeP9g4zvg8aUmwkV5Fw)
Activated workflow "mcp server" (ID: usnJopNEmnZRu8Q4kIRQm)
(node:7) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
Activated workflow "ImportPdfToTable" (ID: grWGMh-JgvDei405wsn8F)
Activated workflow "ToolsGoogleCalendarAgendamentoV4" (ID: bCeD5uQ4ufOd-9sS47g6c)
Activated workflow "ToolsPurchase" (ID: zpU9mGvcB5WGpJHV7Ba6u)
Activated workflow "ToolsCustomerChatCommerce" (ID: oe0gyA5wHP-4has7RJwq6)
Activated workflow "ChatbotAtendimentonNew" (ID: 5xTCd3rOYzWupzyiQpfjI)
Editor is now accessible via:
https://n8n.john-costa.shop
Enqueued execution 209 (job 76)
Execution 209 (job 76) finished
Enqueued execution 210 (job 77)
Execution 210 (job 77) finished

container logs n8n_n8n_task_runners:

2026/03/24 16:06:29 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:06:29 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:06:43 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:06:53 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:06:55 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:06:55 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:06:56 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:06:56 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:06:56 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:07:09 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:07:19 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:07:24 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:07:24 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:07:24 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:07:24 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:07:24 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:07:37 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:07:48 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:07:50 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:07:50 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:07:50 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:07:50 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:07:51 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:08:04 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:08:14 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:08:21 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:08:21 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:08:22 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:08:22 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:08:22 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:08:35 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:08:45 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:08:55 WARN [launcher:js] Found runner unresponsive (3/6)
2026/03/24 16:09:00 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:09:00 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:09:01 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:09:01 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:09:01 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:09:14 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:09:24 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:09:30 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:09:30 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:09:30 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:09:30 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:09:30 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:09:44 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:09:54 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:09:59 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:09:59 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:09:59 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:09:59 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:09:59 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:10:12 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:10:22 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:10:30 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:10:30 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:10:30 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:10:30 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:10:31 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:10:44 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:10:54 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:10:59 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:10:59 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:10:59 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:10:59 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:11:00 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:11:13 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:11:23 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:11:33 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:11:33 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:11:33 WARN [launcher:js] Found runner unresponsive (3/6)
2026/03/24 16:11:33 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:11:33 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:11:34 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:11:47 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:11:57 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:12:04 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:12:04 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:12:05 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:12:05 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:12:05 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:12:18 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:12:28 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:12:36 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:12:36 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:12:38 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:12:38 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:12:38 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:12:51 WARN [launcher:js] Found runner unresponsive (1/6)
2026/03/24 16:13:01 WARN [launcher:js] Found runner unresponsive (2/6)
2026/03/24 16:13:11 WARN [launcher:js] Found runner unresponsive (3/6)
2026/03/24 16:13:18 ERROR [runner:js] Error: Failed to connect to n8n task broker at n8n_n8n_worker:5679
2026/03/24 16:13:18 ERROR [runner:js] Details: Unexpected server response: 403
2026/03/24 16:13:19 ERROR [launcher:js] Runner process exited with error: exit status 1
2026/03/24 16:13:19 INFO  [launcher:js] Waiting for task broker to be ready...
2026/03/24 16:13:26 INFO  [launcher:js] Waiting for launcher's task offer to be accepted...
2026/03/24 16:15:38 ERROR [launcher:js] Failed to execute `launch` command: failed to fetch grant token for runner: exhausted retries to fetch grant token: gave up retrying operation `grant-token-fetch` on reaching max retry time 1m0s, last error: failed to fetch grant token: Post "http://n8n_n8n_worker:5679/runners/auth": read tcp 10.0.3.93:39140->10.0.3.80:5679: read: connection reset by peer
2026/03/25 16:11:05 WARN  [launcher:py] Task broker is down, launcher will try to reconnect...
2026/03/25 16:11:10 INFO  [launcher:py] Waiting for task broker to be ready...
2026/03/25 16:15:25 INFO  [launcher:py] Waiting for launcher's task offer to be accepted...

container logs n8n_n8n_webhook:

Starting n8n webhook process...
n8n ready on ::, port 5678
[license SDK] Skipping renewal on init: renewOnInit is disabled in config
[license SDK] Skipping renewal on init: autoRenewEnabled is disabled in config
[license SDK] Skipping renewal on init: license cert is not due for renewal
Version: 2.11.4
Webhook listener waiting for requests.
Execution 210 (job 77) finished

containers logs n8n_n8n_worker:

n8n Task Broker ready on 0.0.0.0, port 5679
[license SDK] Skipping renewal on init: renewOnInit is disabled in config
[license SDK] Skipping renewal on init: autoRenewEnabled is disabled in config
[license SDK] Skipping renewal on init: license cert is not due for renewal
Database connection timed out
n8n worker is now ready
 * Version: 2.11.4
 * Concurrency: 5
Database connection timed out
Registered runner "launcher-python" (4de57c0f6dc7c712) 
Database connection recovered
Worker started execution 209 (job 76)
Task request timed out
Error: Task request timed out
    at ErrorReporter.wrap (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@opentelemetry+exporter-trace-otlp_9f358c3eeaef0d2736f54ac9757ada43/node_modules/n8n-core/src/errors/error-reporter.ts:308:37)
    at ErrorReporter.error (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@opentelemetry+exporter-trace-otlp_9f358c3eeaef0d2736f54ac9757ada43/node_modules/n8n-core/src/errors/error-reporter.ts:294:25)
    at LocalTaskRequester.requestExpired (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:309:22)
    at LocalTaskRequester.onMessage (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:272:10)
    at TaskBroker.handleRequestTimeout (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:120:50)
    at Timeout.<anonymous> (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:107:9)
    at listOnTimeout (node:internal/timers:605:17)
    at processTimers (node:internal/timers:541:7)
Task request timed out after 60 seconds
Worker finished execution 209 (job 76)
Worker started execution 210 (job 77)
Task request timed out
Error: Task request timed out
    at ErrorReporter.wrap (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@opentelemetry+exporter-trace-otlp_9f358c3eeaef0d2736f54ac9757ada43/node_modules/n8n-core/src/errors/error-reporter.ts:308:37)
    at ErrorReporter.error (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@opentelemetry+exporter-trace-otlp_9f358c3eeaef0d2736f54ac9757ada43/node_modules/n8n-core/src/errors/error-reporter.ts:294:25)
    at LocalTaskRequester.requestExpired (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:309:22)
    at LocalTaskRequester.onMessage (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:272:10)
    at TaskBroker.handleRequestTimeout (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:120:50)
    at Timeout.<anonymous> (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:107:9)
    at listOnTimeout (node:internal/timers:605:17)
    at processTimers (node:internal/timers:541:7)
Task request timed out after 60 seconds
Worker finished execution 210 (job 77)

looks like the runner container is still from the old deployment — the errors in its logs are from yesterday. force redeploy it with docker service update --force n8n_n8n_task_runners and see if the JS runner registers after that.

also worth checking: your editor logs show the task broker starting on port 5679 there too, not just the worker. make sure N8N_RUNNERS_TASK_BROKER_URI is pointing at the right service.

broker uri in the runners needs to match the actual swarm service name for your worker — if youre using http://n8n_worker:5679 but the service is named differently, connection fails silently and code nodes timeout. check the docker logs in the runners container, should show connection errors if the uri is wrong

That’s correct!

n8n_task_runners:
    image: n8nio/runners:2.11.4
    
    environment:
      # Conecta ao worker via HTTP (porta 5679)
      N8N_RUNNERS_TASK_BROKER_URI: http://n8n_n8n_worker:5679
      
      # Token de autenticação (MESMO em todos!)
      N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
      
      # Permite bibliotecas externas
      NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL:-moment,lodash}
      
      # Timezone
      GENERIC_TIMEZONE: America/Sao_Paulo
      TZ: America/Sao_Paulo
    
    depends_on:
      - n8n_worker
    
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      resources:
        limits:
          cpus: '1.5'
          memory: 3072M
      restart_policy:
        condition: any
        delay: 5s

hi @John_da_Costa_Goncal

From an architectural perspective, this flow should be:

Workflow > Worker > Task Broker > Runner > JavaScript execution > Result > Worker

In n8n v2+, Code nodes run through task runners, so when you see Task request timed out after 60 seconds, it usually means the worker submitted the task, but no runner picked it up in time.

Given the earlier 403, failed to fetch grant token, and invalid or expired grant token errors, this seems to be happening during the runner–broker handshake. The broker is up, but the runner isn’t being accepted as a valid execution consumer.

I’d focus on verifying the actual runtime values of N8N_RUNNERS_AUTH_TOKEN and related env vars inside both the worker and task_runners containers after a full redeploy, rather than relying only on the Portainer UI. The database timeouts may add instability, but they look secondary here.

I hope everything goes well :dizzy:

yeah service name looks right from your screenshot. if the broker is up but the runner still cant register, the auth token is almost always the issue in swarm — the env var can look correct in portainer but not actually resolve at runtime. worth running docker service inspect n8n_n8n_task_runners --format '{{range .Spec.TaskTemplate.ContainerSpec.Env}}{{println .}}{{end}}' to confirm the token got injected correctly.