Your n8n server is configured to use a secure cookie, however you are either visiting this via an insecure URL, or using Safari

This might be a long one. Please bare with me.

System Info:

  • n8n version: 1.68.0
  • Database (default: SQLite): PostgreSQL
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):**default?
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker
  • **Operating system:**Ubuntu Server(latest)

I deployed n8n using Docker compose on Ubuntu Server 24.04.1 LTS. and encountered the error in the title.

I changed -N8N_SECURE_COOKIE to false, and I’m able to access n8n, though not securely. To fix this, I set up a proxy host for n8n in an Nginx Proxy Manager container and now the weirdest thing is happening:

I can only access the proxy by adding the container ports. For example n8n.mydomain.com:5678. If I don’t add ‘5678’ at the end, I get a 404 error.

I have a million other containers using proxy hosts on NPM and this is the only one giving me this issue.

Here’s the format of my docker-compose.yml file. I’ve tried different variations of this like specifying the host (ip address, or my domain), explicitly declaring the network the container belongs to (e.g. networks: nginx-network, matching the NPM container):

version: '3.8'

services:
  n8n:
    image: n8nio/n8n
    container_name: n8n
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=pass
      - N8N_PROTOCOL=https
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=email
      - N8N_BASIC_AUTH_PASSWORD=pass
      - N8N_SECURE_COOKIE=false
    volumes:
      - /home/erm/docker/n8n/n8n_data:/data  # Bind mount for n8n data
    ports:
      - "5678:5678"
  postgres:
    image: postgres:latest
    container_name: postgres
    environment:
      - POSTGRES_DB=n8n
      - POSTGRES_USER=n8n
      - POSTGRES_PASSWORD=pass
    volumes:
      - /home/erm/docker/n8n/database_n8n:/var/lib/postgresql/data # save DB to 'database_n8n'

Since I’m only seeing the issue on n8n, I’m inclined to think it is specific to this container and not NPM, but I’m open to any suggestions from the community.

Hello,

The config with

ports:
  - "5678:5678"

will bind the port 5678 to the host. Which means when accessing n8n.mydomain.com:5678, it bypasses the nginx proxy and directly connects to the n8n container.

It looks like your nginx config is the problem here and doesn’t know how to map your n8n subdomain with your n8n container. Since it doesn’t return 503/502 but a 404, I would likely expect that nginx doesn’t know how to route the n8n subdomain.

I hope this helps!

1 Like