Code in Python (Native) (Beta) not working

Hello.
I want to try the new python native mode, so I made a docker compose to try it locally.
My problem is that for some reason the code is running but stays in “executing code” forever. I don’t know if my task runner has a problem or something if its my docker compose so I want to ask for help to verify it. Can someone help me with the docker compose?

THX!

volumes:
  db_storage:
  n8n_storage:

services:
  postgres:
    image: postgres:16
    restart: always
    environment:
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_DB
      - POSTGRES_NON_ROOT_USER
      - POSTGRES_NON_ROOT_PASSWORD
    volumes:
      - db_storage:/var/lib/postgresql/data
      - ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
      interval: 5s
      timeout: 5s
      retries: 10
    networks:
      - n8n_net

  n8n:
    image: n8nio/n8n:1.111.0
    restart: always
    container_name: n8n-main
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
      - DB_POSTGRESDB_USER=${POSTGRES_USER}
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
      - N8N_RUNNERS_ENABLED=true
      - N8N_NATIVE_PYTHON_RUNNER=true
      - N8N_RUNNERS_MODE=internal
      - N8N_RUNNERS_AUTH_TOKEN=test 
      - N8N_LOG_LEVEL=debug 
    ports:
      - 5678:5678
    expose:
      - "5679"
    links:
      - postgres
    networks:
      - n8n_net
    volumes:
      - n8n_storage:/home/node/.n8n
    depends_on:
      postgres:
        condition: service_healthy


  task-runners:
    image: n8nio/runners:1.111.0
    container_name: n8n-runners
    environment:
      - N8N_RUNNERS_AUTH_TOKEN=test
      - N8N_RUNNERS_TASK_BROKER_URI=http://n8n-main:5679
      - NODE_FUNCTION_ALLOW_BUILTIN=*
      - NODE_FUNCTION_ALLOW_EXTERNAL=*
      - N8N_RUNNERS_STDLIB_ALLOW=*
      - N8N_RUNNERS_EXTERNAL_ALLOW=*
      - N8N_RUNNERS_LAUNCHER_LOG_LEVEL=debug
    expose:
    - "5680"
    depends_on:
      - n8n
    networks:
      - n8n_net


networks:
  n8n_net:
    driver: bridge

Information on your n8n setup

  • n8n version: 1.111.0
  • Database (default: SQLite): Postgres
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Windows (no WSL)

Would you like to share the code and the workflow you are running, so that we could actually look at the problem?

I have the same issue where the “executing code” runs forever
even if i run a simple print(“Hello, World“)

Information on your n8n setup

  • n8n version: 1.112.6

  • Database (default)

  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker

  • Operating system: Ubuntu server

give me your docker compose file i can help

Main n8n Container Environment Variables

To enable the runners, I added the following environment variables to my main n8n container:

  • For Database: Shifted from SQLite to PostgreSQL.

    • DB_TYPE=postgresdb

    • DB_POSTGRESDB_HOST=n8n-postgres

    • DB_POSTGRESDB_PORT=5432

    • DB_POSTGRESDB_DATABASE=n8n-postgres

    • DB_POSTGRESDB_USER=xxxxx

    • DB_POSTGRESDB_PASSWORD=xxxxxx

  • For the Runner:

    • N8N_RUNNERS_ENABLED=true

    • N8N_NATIVE_PYTHON_RUNNER=true

    • N8N_RUNNERS_BROKER_LISTEN_ADDRESS=0.0.0.0

    • N8N_RUNNERS_MODE=EXTERNAL

    • N8N_RUNNERS_AUTH_TOKEN=xxxxxxx

Python Runner docker-compose.yml Snippet

This is the service I added to my stack to handle Python executions.

text
version: '3.8'

services:
  # ... (other services like postgres are omitted for clarity)

  # Python and JS Code Runner
  n8n-python-runner:
    image: n8nio/runners:1.114.2
    container_name: n8n-python-runner
    restart: always
    environment:
      - N8N_RUNNERS_BROKER=ws://n8n:5679
      - N8N_RUNNERS_AUTH_TOKEN=xxxxxx
    depends_on:
      n8n-postgres:
        condition: service_healthy

I have confirmed network connectivity between the runner and the main n8n instance with both ping and telnet, so I believe my networking is correct

Despite the runner logs indicating it is “waiting for task broker,” my telnet test from inside the runner container to the main n8n instance on port 5679 connects successfully.

Any help would be appreciated. Thank you.

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