SMTP issue

Describe the problem/error/question

I try to activate SMTP with N8N deploy through Portainer (stack).
Here is the stack used :

version: '3.8'

services:
  postgres_n8n:
    image: postgres:latest
    container_name: postgres_n8n
    restart: always
    environment:
      POSTGRES_USER : user
      POSTGRES_PASSWORD: pass
      POSTGRES_BD: n8n
      PGDATA: /var/lib/postgresql/data/pgdata
      TZ : Europe/Brussels
    ports:
      - 5435:5432
    volumes:
      - /n8n/db/db_storage:/var/lib/postgresql/data
    networks:
      - mynet
  n8n:
    image: n8nio/n8n:latest
    container_name: n8n
    stdin_open: true
    tty: true
    user: user
    restart: always
    environment:
      - "DEBUG=true"
      - "DB_TYPE=postgresdb"
      - "DB_POSTGRESDB_HOST=192.168.0.11"
      - "DB_POSTGRESDB_PORT=5435"
      - "DB_POSTGRESDB_DATABASE=n8n"
      - "DB_POSTGRESDB_USER=user"
      - "DB_POSTGRESDB_PASSWORD=pass"
      - "N8N_SECURE_COOKIE=true"
      # Config SMTP
      - "N8N_EMAIL_MODE=smtp"
      - "N8N_SMTP_HOST=ex4.mail.ovh.net"
      - "N8N_SMTP_PORT=587"
      - "N8N_SMTP_SSL=false"
      - "[email protected]"
      - "N8N_SMTP_PASS=pass"
      - "[email protected]"
    volumes:
      - /n8n/n8n_storage/:/home/node/.n8n/
      - /certs:/certs
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.n8n.rule=Host(`n8n.mydomain.com`)"
      - "traefik.http.routers.n8n.entrypoints=websecure"
      - "traefik.http.routers.n8n.tls.certresolver=myRes"
    networks:
      - mynet
networks:
  mynet:
    external: true

What is the error message (if any)?

The error I receive within the container log:

ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.

23

at Object.xForwardedForHeader (/usr/local/lib/node_modules/n8n/node_modules/express-rate-limit/dist/index.cjs:166:13)

24

at Object.wrappedValidations.<computed> [as xForwardedForHeader] (/usr/local/lib/node_modules/n8n/node_modules/express-rate-limit/dist/index.cjs:338:22)

25

at Object.keyGenerator (/usr/local/lib/node_modules/n8n/node_modules/express-rate-limit/dist/index.cjs:593:20)

26

at /usr/local/lib/node_modules/n8n/node_modules/express-rate-limit/dist/index.cjs:644:32

27

at /usr/local/lib/node_modules/n8n/node_modules/express-rate-limit/dist/index.cjs:625:5 {

28

code: 'ERR_ERL_UNEXPECTED_X_FORWARDED_FOR',

29

help: 'https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/'

Information on your n8n setup

  • n8n version: n8n:latest
  • Database (default: SQLite): postgre
  • Running n8n via (Docker, npm, n8n cloud, desktop app): portainer/docker
  • Operating system: Debian

Hey @Daplayzz,

Welcome to the community :cake:

The error in your log is not related to the SMTP option, What error are you seeing when trying to use one of the features that needs SMTP like a password reset?

To remove the error you are seeing can you try setting N8N_PROXY_HOPS to 1 in your config.

Hello Jon,

Yes, indeed, I check the log, not my mailbox. :face_in_clouds:

Thank you for your help. Indeed, N8N_PROXY_HOPS helped for the error :slight_smile:

Ticket can be closed. Thank you so much !

1 Like

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