Multiple n8n instances, BAD GATEWAY on my 2nd n8n

  • Running n8n via docker compose

I’m trying to run 2 n8n instances on a single vps with docker-compose.
The first n8n is an older version, 0.9 something. I’d like to run the latest version on a different docker file but using same traefik.
I have 2 separated docker-compose.yml files and in a different folder too.
I can access my old n8n but i can’t access my 2nd n8n named n8n_2024.
It returns Bad Gateway.

I have followed this step

I have made sure that both setup have different labels and ports.

Please help, below are my yml configs

My first n8n docker compose

version: "3"

services:
  traefik:
    image: "traefik"
    restart: always
    command:
      - "--api=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
      - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
      - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ${DATA_FOLDER}/letsencrypt:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - traefik_proxy
  n8n:
    image: n8nio/n8n
      #user: "baxia:baxia"
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=web,websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
      - traefik.http.routers.n8n.middlewares=n8n@docker,corsheaders@docker
      - traefik.http.middlewares.corsheaders.headers.accesscontrolallowheaders=Content-Type,Authorization
      - traefik.http.middlewares.corsheaders.headers.accesscontrolallowcredentials=true
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER
      - N8N_BASIC_AUTH_PASSWORD
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=Europe/Athens
      - TZ=Europe/Athens
      - QUEUE_HEALTH_CHECK_ACTIVE=true
      - EXECUTIONS_DATA_SAVE_ON_ERROR=all
      - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
      - EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
      - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=true
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=1
      -  EXECUTIONS_TIMEOUT_MAX=7200
      - DB_SQLITE_VACUUM_ON_STARTUP=true
      - NODE_FUNCTION_ALLOW_EXTERNAL=mout,iso-3166-1-alpha-2,mysql,@hubspot/api-client,axios,sanitize-html,dom-parser,bottleneck,node-html-parser,html-table-to-json,cheerio
      - NODE_FUNCTION_ALLOW_INTERNAL=axios,sanitize-html
      - N8N_CUSTOM_HEADER=default-src 'self'; connect-src 'self' https://ph.n8n.io https://api.n8n.io;
    volumes:
      - ${DATA_FOLDER}/.n8n:/home/node/.n8n
      - /root/n8n/node_modules/dom-parser:/usr/local/lib/node_modules/dom-parser
      - /root/n8n/node_modules/bottleneck:/usr/local/lib/node_modules/bottleneck
      - /root/n8n/node_modules/node-html-parser:/usr/local/lib/node_modules/node-html-parser
      - /root/n8n/node_modules/html-table-to-json:/usr/local/lib/node_modules/html-table-to-json
      - /root/n8n/node_modules/cherio:/usr/local/lib/node_modules/cheerio
      - /root/n8n/node_modules/@hubspot:/usr/local/lib/node_modules/@hubspot
      - /root/n8n/node_modules/iso-3166-1-alpha-2:/usr/local/lib/node_modules/iso-3166-1-alpha-2
      - /root/n8n/node_modules/mout:/usr/local/lib/node_modules/mout
      - /root/n8n/node_modules/mysql:/usr/local/lib/node_modules/mysql
      - ${DATA_FOLDER}/custom:/home/node/.n8n/custom
      - /root/ssl/:/etc/ssl/
      - /root/ssl/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt
    command: sh -c "NODE_OPTIONS='--max-old-space-size=4096' n8n start"
    networks:
      - traefik_proxy
networks:
  traefik_proxy:
    external: true

second n8n on a separate

version: "3.7"

services:
  n8n_2024:
    container_name: aladdin_2024
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:7182:5678"
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n_2024.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n_2024.tls=true
      - traefik.http.routers.n8n_2024.entrypoints=web,websecure
      - traefik.http.routers.n8n_2024.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n_2024.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n_2024.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n_2024.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n_2024.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n_2024.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n_2024.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n_2024.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n_2024.headers.STSPreload=true
      - traefik.http.routers.n8n_2024.middlewares=n8n_2024@docker,corsheaders@docker
      - traefik.http.middlewares.corsheaders.headers.accesscontrolallowheaders=Content-Type,Authorization
      - traefik.http.middlewares.corsheaders.headers.accesscontrolallowcredentials=true
      - traefik.http.services.n8n_2024.loadbalancer.server.port=5678
    environment:
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=7182
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=Europe/Athens
      - TZ=Europe/Athens
      - QUEUE_HEALTH_CHECK_ACTIVE=true
      - EXECUTIONS_DATA_SAVE_ON_ERROR=all
      - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
      - EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
      - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=true
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=1
      - DB_SQLITE_VACUUM_ON_STARTUP=true
      - NODE_FUNCTION_ALLOW_EXTERNAL=mout,iso-3166-1-alpha-2,mysql,@hubspot/api-client,axios,sanitize-html,dom-parser,bottleneck,node-html-parser,html-table-to-json,cheerio
      - NODE_FUNCTION_ALLOW_INTERNAL=axios,sanitize-html
      - N8N_CUSTOM_HEADER=default-src 'self'; connect-src 'self' https://ph.n8n.io https://api.n8n.io;
    volumes:
      - n8n_2024_data:/home/node/.n8n_data_2024
    networks:
      - traefik_proxy
networks:
  traefik_proxy:
    external: true

volumes:
  n8n_2024_data:
    external: true

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

problem solved, fixed below, changed port to a different port

- traefik.http.services.n8n_2024.loadbalancer.server.port=7182
1 Like

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