Problem setting up owner Request failed with status code 401

I am using version 1.32.1
After starting with Docker Compose below, when setting account information, I get this error:

Problem setting up owner
Request failed with status code 401

Please guide me if you know what the problem could be. :pray:

**

Docker-Compose:

**

version: '3.8'
#==============================================================
services:

  postgres:
    restart: unless-stopped
    image: postgres:16
    container_name: postgres
    hostname: postgres
    networks:
      - n8n-net
    ports:
        - "5432:5432"
    volumes:
        - /volume/n8n/postgresql:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=n8n_db
      - POSTGRES_USER=n8n_app
      - POSTGRES_PASSWORD=1111111111

#+++++++++++++++++++++++++++++++++++++++++++         
  n8n_app:
    restart: unless-stopped
    image: n8nio/n8n:1.32.1
    container_name: n8n_app
    hostname: n8n_app
    networks:
      - n8n-net
    ports:
        - "5678:5678"
    volumes:
        - /volume/n8n/data:/home/node/.n8n
    environment:
      - N8N_PROTOCOL=http
      - N8N_HOST=0.0.0.0
      - WEBHOOK_URL=http://0.0.0.0/ 
      - NODE_ENV=production
      - N8N_ENCRYPTION_KEY=XsfWKTgTS4uQiLlIP2qNYj11C
      - N8N_LOG_LEVEL=error

      - EXECUTIONS_DATA_SAVE_ON_ERROR=all
      - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
      - EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
      - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=72
      - EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000

      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=192.168.1.1
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n_db
      - DB_POSTGRESDB_USER=n8n_app
      - DB_POSTGRESDB_PASSWORD=1111111111

      - EXECUTIONS_MODE=queue
      - EXECUTIONS_QUEUE=redis
      - QUEUE_HEALTH_CHECK_ACTIVE=true
      - QUEUE_BULL_REDIS_HOST=192.168.1.1
      - QUEUE_BULL_REDIS_PORT=6379
      - QUEUE_BULL_REDIS_PASSWORD=1111111111

      - N8N_DISABLE_PRODUCTION_MAIN_PROCESS=true
    depends_on:
      - postgres
#+++++++++++++++++++++++++++++++++++++++++++ 
  n8n_worker:
    restart: unless-stopped
    image: n8nio/n8n:1.32.1
    container_name: n8n_worker
    hostname: n8n_worker
    networks:
      - n8n-net
#    ports:
#        - "5678:5678"
    volumes:
        - /volume/n8n/data:/home/node/.n8n
    environment:
      - N8N_PROTOCOL=http
      - N8N_HOST=0.0.0.0
      - WEBHOOK_URL=http://0.0.0.0/
      - NODE_ENV=production
      - N8N_ENCRYPTION_KEY=XsfWKTgTS4uQiLlIP2qNYj11C
      - N8N_LOG_LEVEL=error

      - EXECUTIONS_DATA_SAVE_ON_ERROR=all
      - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
      - EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
      - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=72
      - EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000

      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=192.168.1.1
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n_db
      - DB_POSTGRESDB_USER=n8n_app
      - DB_POSTGRESDB_PASSWORD=1111111111

      - EXECUTIONS_MODE=queue
      - EXECUTIONS_QUEUE=redis
      - QUEUE_HEALTH_CHECK_ACTIVE=true
      - QUEUE_BULL_REDIS_HOST=192.168.1.1
      - QUEUE_BULL_REDIS_PORT=6379
      - QUEUE_BULL_REDIS_PASSWORD=1111111111

    command: worker #--concurrency=10
    depends_on:
      - n8n_app
#+++++++++++++++++++++++++++++++++++++++++++       
  n8n_webhook:
    restart: unless-stopped
    image: n8nio/n8n:1.32.1
    container_name: n8n_webhook
    hostname: n8n_webhook
    networks:
      - n8n-net
#    ports:
#        - "5678:5678"
    volumes:
        - /volume/n8n/data:/home/node/.n8n
    environment:
      - N8N_PROTOCOL=http
      - N8N_HOST=0.0.0.0
      - WEBHOOK_URL=http://0.0.0.0/
      - NODE_ENV=production
      - N8N_ENCRYPTION_KEY=XsfWKTgTS4uQiLlIP2qNYj11C
      - N8N_LOG_LEVEL=error
      
      - EXECUTIONS_DATA_SAVE_ON_ERROR=all
      - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
      - EXECUTIONS_DATA_SAVE_ON_PROGRESS=true
      - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false

      - EXECUTIONS_DATA_PRUNE=true
      - EXECUTIONS_DATA_MAX_AGE=72
      - EXECUTIONS_DATA_PRUNE_MAX_COUNT=50000

      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=192.168.1.1
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n_db
      - DB_POSTGRESDB_USER=n8n_app
      - DB_POSTGRESDB_PASSWORD=1111111111

      - EXECUTIONS_MODE=queue
      - EXECUTIONS_QUEUE=redis
      - QUEUE_HEALTH_CHECK_ACTIVE=true
      - QUEUE_BULL_REDIS_HOST=192.168.1.1
      - QUEUE_BULL_REDIS_PORT=6379
      - QUEUE_BULL_REDIS_PASSWORD=1111111111

    command: webhook
    depends_on:
      - n8n_app
#+++++++++++++++++++++++++++++++++++++++++++   
networks:
    n8n-net:
        name: n8n-net

Information on your n8n setup

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

Hey @Amin_Pirzadi,

Welcome to the community :raised_hands:

Are you accessing your n8n instance over HTTP or HTTPS? If you are using HTTP you may see this issue and it would be worth trying to set the N8N_SECURE_COOKIE env option to false and seeing if that helps.

1 Like

Hey @Jon ,
Thank you for your good advice.
Problem solved by adding this env.

- N8N_SECURE_COOKIE=false

now I have a problem probably related to this case.
I used simple “webhook” and “Responde to Webhook” in a workflow
It works properly in test mode, But there is an error with the production url.
Is it because of the type of protocol (Http)! used?

Also, I changed the webhook from the get method to the post method.
The result is a 401 error!

I suppose it’s because you have a weird webhook URL :slight_smile:

You should specify a DNS name, not an IP wildcard.

have you tried to open a webhook page in the browser?

  • If the problem was related to webhook_url, it would not give 401 error

  • Also, webhook with test url was not called correctly

I think for url you can use something like this without needing domain name:

  • 0.0.0.0
  • 127.0.0.1
  • localhost

In these cases, n8n is accessible from outside the server with the server’s internet ip.

You don’t have a port set on your webhook url but you are trying to access 5678. I would start by updating WEBHOOK_URL so it matches what you are actually using first but it is possible that it could be related although you have no authentication on the webhook.

1 Like

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

New version [email protected] got released which includes the GitHub PR 8906.