Cant get n8n deployed behind Nginx proxy manager. Can access dashboard locally

Can’t get n8n deployed behind nginx proxy manager. n8n is deployed in a stack in Portainer.

  • n8n version:
  • Database (default: postgres):
  • Running n8n via Docker
  • Operating system: - ubuntu
services:
  postgres:
    image: postgres:16
    container_name: n8n_postgres
    restart: always
    environment:
      POSTGRES_DB: ${DB_POSTGRESDB_DATABASE}
      POSTGRES_USER: ${DB_POSTGRESDB_USER}
      POSTGRES_PASSWORD: ${DB_POSTGRESDB_PASSWORD}
    volumes:
      - n8n_pg_data:/var/lib/postgresql/data
    networks: 
      - n8n-network

  n8n:
    image: n8nio/n8n
    container_name: n8n
    restart: always
    ports:
      - 5678:5678
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${DB_POSTGRESDB_DATABASE}
      - DB_POSTGRESDB_USER=${DB_POSTGRESDB_USER}
      - DB_POSTGRESDB_PASSWORD=${DB_POSTGRESDB_PASSWORD}
      - DB_POSTGRESDB_SCHEMA=${DB_POSTGRESDB_SCHEMA}
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=${N8N_BASIC_AUTH_USER}
      - N8N_BASIC_AUTH_PASSWORD=${N8N_BASIC_AUTH_PASSWORD}
      - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
      - N8N_HOST=${N8N_HOST}
      - WEBHOOK_URL=${WEBHOOK_URL}
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - TZ=${TZ}
      - N8N_PUSH_BACKEND=${N8N_PUSH_BACKEND}
      - N8N_RUNNERS_ENABLED=${N8N_RUNNERS_ENABLED}
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_SECURE_COOKIE=${N8N_SECURE_COOKIE}
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres
    networks:
      - n8n-network

volumes:
  n8n_data:
  n8n_pg_data:

networks:
  n8n-network:
    external: true

.env -

DB_POSTGRESDB_DATABASE=n8n
DB_POSTGRESDB_USER=n8n_user
DB_POSTGRESDB_PASSWORD=n8npass123
DB_POSTGRESDB_SCHEMA=public
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=strongadminpass
N8N_ENCRYPTION_KEY=superSecureRandomKey_ChangeThis123!
N8N_HOST=n8n.domain.live
WEBHOOK_URL=https://n8n.domain.live/
GENERIC_TIMEZONE=Asia/Kolkata
TZ=Asia/Kolkata
N8N_RUNNERS_ENABLED=true
N8N_PUSH_BACKEND=websocket
N8N_SECURE_COOKIE=false/true tried both

For SSL, I am using Cloudflare origin certificates as custom SSL in Nginx Proxy Manager.

When I try to access the n8n on the local network, I can access the dashboard.

I get 504 Gateway time-out when I access https://n8n.domain.live

No errors in n8n logs in Portainer.

Hey @Sri_Ram_Macha,

Welcome to the community!

The 504 timeout suggests nginx can’t reach your n8n contain.

A few things to check:Network connectivity:

  • Make sure your nginx proxy manager container is on the same network as n8n.

Add this to your nginx proxy manager stack:
networks:- n8n-network

  • Change the scheme to https:
    In your proxy host config, change “Scheme” from http to https since you’re using Cloudflare origin certificates.

  • Try the container name instead of IP:
    Change “Forward Hostname/IP” from 192.168.1.127 to n8n (the container name).
    Docker networks resolve container names automatically.

  • Check if n8n is actually listening:

Run docker logs n8n to see if there are any startup errors, and docker exec -it n8n netstat -tlnp to confirm it’s listening on port 5678.

The fact that it works locally suggests n8n is running fine, so it’s likely a networking issue between nginx proxy manager and the n8n container.

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