Workflows Stuck in "Queued" Status After ~60 Seconds of Execution Time

Finally working
Not sure if I have missed or there there could be some more documentation on queue mode

I did the following

  • Added following to respective containers
  • – commands - “worker” and “webhook”
  • – N8N_RUNNERS_MODE

In case anyone need - my working docker-compose for n8n + 1 worker + 1 webhook + redis + postgres

# hard-dependency on core-services stack

volumes:
  n8n_data:
    name: n8n_data
  n8n_webhook:
    name: n8n_webhook
  n8n_worker:
    name: n8n_worker
  redis_data:
    name: redis_data
  postgres_data:
    name: postgres_data

networks:
  backend:
    external: true
    name: backend

# Common environment variables for all n8n-related services
x-n8n-env: &n8n-env
  N8N_PORT: ${N8N_PORT}
  #N8N_SECURE_COOKIE: ${N8N_SECURE_COOKIE}
  N8N_DIAGNOSTICS_ENABLED: ${N8N_DIAGNOSTICS_ENABLED}
  NODE_FUNCTION_ALLOW_EXTERNAL: ${NODE_FUNCTION_ALLOW_EXTERNAL}
  GENERIC_TIMEZONE: ${GENERIC_TIMEZONE}        
  N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
  N8N_USER_FOLDER: ${N8N_USER_FOLDER}
  N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: ${N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS}
  WEBHOOK_URL: ${WEBHOOK_URL}
  N8N_PROTOCOL: ${N8N_PROTOCOL}
  NODE_ENV: ${NODE_ENV}

  # Queue mode config
  QUEUE_BULL_REDIS_HOST: ${QUEUE_BULL_REDIS_HOST}
  QUEUE_BULL_HEALTH_CHECK_ACTIVE: ${QUEUE_BULL_HEALTH_CHECK_ACTIVE}
  QUEUE_BULL_REDIS_PASSWORD: ${QUEUE_BULL_REDIS_PASSWORD}
  EXECUTIONS_MODE: ${EXECUTIONS_MODE}

  # DB config
  DB_TYPE: ${DB_TYPE}
  DB_TABLE_PREFIX: ${DB_TABLE_PREFIX}
  DB_POSTGRESDB_HOST: ${POSTGRES_HOST}
  DB_POSTGRESDB_PORT: ${POSTGRES_PORT}
  DB_POSTGRESDB_DATABASE: ${POSTGRES_DB}
  DB_POSTGRESDB_USER: ${POSTGRES_USER}
  DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}

  # Task runner config
  N8N_RUNNERS_ENABLED: ${N8N_RUNNERS_ENABLED}        
  OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS: ${OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS}
  N8N_RUNNERS_AUTH_TOKEN: ${N8N_RUNNERS_AUTH_TOKEN}
  N8N_TASK_BROKER_URL: ${N8N_TASK_BROKER_URL}
  N8N_COMMAND_RESPONSE_URL: ${N8N_COMMAND_RESPONSE_URL}
  N8N_TASK_BROKER_PORT: ${N8N_TASK_BROKER_PORT}

x-n8n-common: &n8n-common
  image: n8nio/n8n:latest
  user: root:root
  restart: unless-stopped
  links:
    - postgres
    - redis 
  networks:
    - backend
  depends_on: &depends-on-defaults
    redis:
      condition: service_healthy
    postgres:
      condition: service_healthy
  healthcheck:
    test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:5678/health || exit 1 "]
    interval: 5s
    timeout: 5s
    retries: 1
    start_period: 30s

services:
  redis:
    image: redis
    container_name: redis
    restart: unless-stopped
    command: redis-server --save 60 1 --loglevel VERBOSE --requirepass ${QUEUE_BULL_REDIS_PASSWORD}
    volumes:
      - redis_data:/data
    ports:
      - "6379:6379"
    networks:
      - backend
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
      interval: 1s
      timeout: 3s

  postgres:
    image: postgres
    container_name: postgres
    restart: unless-stopped
    environment:
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - PGDATA=${PGDATA}
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ${SETUP_ROOT_FOLDER}/postgres/init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
    ports:
      - 5432:5432
    networks:
      - backend
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 30s

  n8n:
    <<: *n8n-common
    container_name: n8n
    environment: 
      <<: *n8n-env
      N8N_RUNNERS_MODE: ${N8N_RUNNERS_MODE_SERVER}
    volumes:
      - n8n_data:${N8N_ROOT_FOLDER}
    ports:
      - "5678:5678"
      - "5679:5679"

  n8n-worker:
    <<: *n8n-common
    container_name: n8n-worker
    command: worker    
    environment: 
      <<: *n8n-env
      N8N_CONCURRENCY_PRODUCTION_LIMIT: 10 
      N8N_GRACEFUL_SHUTDOWN_TIMEOUT: 300  
      N8N_RUNNERS_MODE: ${N8N_RUNNERS_MODE_INTERNAL}
    volumes:
      - n8n_worker:${N8N_ROOT_FOLDER}
    depends_on:
      n8n:
        condition: service_healthy
      <<: *depends-on-defaults 

  n8n-webhook:
    <<: *n8n-common
    container_name: n8n-webhook
    command: webhook
    environment:
      <<: *n8n-env
      N8N_RUNNERS_MODE: ${N8N_RUNNERS_MODE_INTERNAL}
    volumes:
      - n8n_webhook:${N8N_ROOT_FOLDER}
    depends_on:
      n8n:
        condition: service_healthy
      <<: *depends-on-defaults   

Thanks @King_Samuel_David . I will note these and will follow in case of further issues

2 Likes