N8N Docker Compose with Worker, workflow url is localhost:5678

Hey i got a issue with my new Docker Compose:

version: '3.8'

volumes:
  db_storage:
    external: true
    name: n8n-postgres_db_storage
  n8n_data:
    external: true
    name: n8n-postgres_n8n_data
  redis_storage:

services:
  postgres-worker:
    image: postgres:16
    restart: always
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_NON_ROOT_USER: ${POSTGRES_NON_ROOT_USER}
      POSTGRES_NON_ROOT_PASSWORD: ${POSTGRES_NON_ROOT_PASSWORD}
    volumes:
      - db_storage:/var/lib/postgresql/data
      - /opt/portainer/scripts/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
    ports:
      - "5432:5432"
    networks:
      - n8n-net
    command: postgres -c listen_addresses='*'

  redis:
    image: redis:6-alpine
    restart: always
    volumes:
      - redis_storage:/data
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
      interval: 5s
      timeout: 5s
      retries: 10
    networks:
      - n8n-net

  n8n-main:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres-worker
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
      - DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - EXECUTIONS_MODE=queue
      - QUEUE_BULL_REDIS_HOST=redis
      - QUEUE_HEALTH_CHECK_ACTIVE=true
      - N8N_HOST=${N8N_HOST} // -> redacted.domain.com
      - N8N_PORT=5679
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=${WEBHOOK_URL} // -> https://redacted.domain.com/
      - GENERIC_TIMEZONE=Europe/Berlin
      - N8N_EMAIL_MODE=smtp
      - N8N_SMTP_HOST=${N8N_SMTP_HOST}
      - N8N_SMTP_PORT=${N8N_SMTP_PORT}
      - N8N_SMTP_SSL=${N8N_SMTP_SSL}
      - N8N_SMTP_SENDER=${N8N_SMTP_SENDER}
      - N8N_DEFAULT_BINARY_DATA_MODE=filesystem
      - N8N_LOG_LEVEL=warn
      - NODE_FUNCTION_ALLOW_BUILTIN=*
      - NODE_FUNCTION_ALLOW_EXTERNAL=axios
      - N8N_ONBOARDING_FLOW_DISABLED=false
      - N8N_DIAGNOSTICS_ENABLED=false
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false
      - N8N_RUNNERS_ENABLED=true
      - OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS=true
      - N8N_RUNNERS_MODE=external
      - N8N_RUNNERS_AUTH_TOKEN=${N8N_RUNNERS_AUTH_TOKEN}
      - N8N_RUNNERS_BROKER_PORT=5681
    ports:
      - "5679:5679"
    volumes:
      - n8n_data:/home/node/.n8n
      - /mnt/n8n_files:/home/node/files
    depends_on:
      postgres-worker:
        condition: service_healthy
      redis:
        condition: service_healthy
    networks:
      - n8n-net

  n8n-worker-template: &n8n-worker-template
    image: docker.n8n.io/n8nio/n8n
    restart: always
    command: worker
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres-worker
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
      - DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - EXECUTIONS_MODE=queue
      - QUEUE_BULL_REDIS_HOST=redis
      - N8N_RUNNERS_AUTH_TOKEN=${N8N_RUNNERS_AUTH_TOKEN}
      - N8N_RUNNERS_TASK_BROKER_URI=${WEBHOOK_URL}:${N8N_RUNNERS_BROKER_PORT} // https://redacted.domain.com:Port
    depends_on:
      - redis
      - postgres-worker
    volumes:
      - n8n_data:/home/node/.n8n
    networks:
      - n8n-net

  n8n-worker-1:
    <<: *n8n-worker-template
  n8n-worker-2:
    <<: *n8n-worker-template
  n8n-worker-3:
    <<: *n8n-worker-template

networks:
  n8n-net:
    driver: bridge
    ipam:
      config:
        - subnet: 172.21.0.0/16

Webhooks are working fine with the domain but the Error Trigger outputs:

“http://localhost:5678/workflow/Jbe7iKKIMiBAj0XJ/executions/73216”,

just like the smtp approve buttons in a mail it points to localhost:5678/xxxx

im not even using the Port 5678 in my Docker Compose

can someone help me and fix my docker compose?

Just a hunch (haven’t tried this to see), but the first thing I would try is duplicating the URL-related environment variables in the main node to the worker nodes.

      - N8N_PORT=5679
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=${WEBHOOK_URL} // -> https://redacted.domain.com/
2 Likes

Oh yes, I’m stupid. Thanks, I thought I had already tried that.

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