Problems with Python code node in n8n

Hello!
I got the error in my n8n workflow on code node (I used python):
Error: Task request timed out after 60 seconds at LocalTaskRequester.requestExpired (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:304:17) 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:124:50) at Timeout. (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:110:9) at listOnTimeout (node:internal/timers:605:17) at processTimers (node:internal/timers:541:7)

My code:

snippet_text = _items[0]["json"]["snippet"]
return [{'json': {'snippet': snippet_text}}]

I launch n8n via docker compose.
Here my docker compose config:


services:

  n8n:

    image: n8nio/n8n:latest

    container_name: n8n-main

    restart: always

    environment:

      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false

      - N8N_BLOCK_ENV_ACCESS_IN_NODE=false

      - N8N_HOST=://example.com

      - N8N_PORT=5678

      - WEBHOOK_URL=http://localhost:5678/

      - DB_TYPE=postgresdb

      - DB_POSTGRESDB_HOST=postgres

      - DB_POSTGRESDB_PORT=5432

      - DB_POSTGRESDB_DATABASE=n8n

      - DB_POSTGRESDB_USER=n8n_user

      - DB_POSTGRESDB_PASSWORD=your_postgres_password

      - N8N_RUNNERS_ENABLED=true

      - N8N_RUNNERS_MODE=external

      - N8N_RUNNERS_AUTH_TOKEN=super_secure_token_change_me

      - N8N_RUNNERS_BROKER_PORT=5679

      - N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0

    ports:

      - "5678:5678"

      - "5679:5679"

    volumes:

      - n8n_data:/home/node/.n8n

    depends_on:

      postgres:

        condition: service_healthy



  n8n-runner:

    image: n8nio/runners:latest

    container_name: n8n-task-runner

    restart: always

    environment:

    - N8N_RUNNERS_ENABLED_MODES=python

      - N8N_RUNNERS_BROKER_URL=ws://n8n:5679

      - N8N_RUNNERS_AUTH_TOKEN=super_secure_token_change_me

    depends_on:

      - n8n



  postgres:

    image: postgres:15-alpine

    container_name: n8n-postgres

    restart: always

    environment:

      - POSTGRES_USER=n8n_user

      - POSTGRES_PASSWORD=your_postgres_password  

      - POSTGRES_DB=n8n

    volumes:

      - postgres_data:/var/lib/postgresql/data

    healthcheck:

      test: \["CMD-SHELL", "pg_isready -U n8n_user -d n8n"\]

      interval: 5s

      timeout: 5s

      retries: 5



volumes:

  n8n_data:

  postgres_data:

How I can fix that?

Thanks in advance!

Welcome @Quent!

Your runner service has two wrong environment variable names that cause the timeout. Replace N8N_RUNNERS_BROKER_URL with N8N_RUNNERS_TASK_BROKER_URI=http://n8n:5679, and replace N8N_RUNNERS_ENABLED_MODES with N8N_RUNNERS_ENABLED_TASK_TYPES=javascript,python. Also fix the YAML indentation in your runner’s environment block - all items need consistent leading spaces. Here’s the corrected n8n-runner service:

n8n-runner:
image: n8nio/runners:latest
container_name: n8n-task-runner
restart: always
environment:

  • N8N_RUNNERS_ENABLED_TASK_TYPES=javascript,python
  • N8N_RUNNERS_TASK_BROKER_URI=http://n8n:5679
  • N8N_RUNNERS_AUTH_TOKEN=super_secure_token_change_me
    depends_on:
  • n8n

After updating, run docker compose down && docker compose up -d. If timeouts still happen, you can add N8N_RUNNERS_TASK_REQUEST_TIMEOUT=120 to the n8n service environment to give the runner more time.

Thank you!