-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
n8n deployed on docker seems to add extra new line to username and password when using secrets #10818
Comments
Hey @bartoszrapp, We have created an internal ticket to look into this which we will be tracking as "GHC-232" |
As an additional information. It is for sure a problem on n8n side. Postgres set with secrets and _FILE and n8n set with regular password env variable works perfectly fine. Only when I use xxx_FILE on n8n the error manifestates. |
Hey @bartoszrapp Just to confirm your secret file doesn't have a new line character at the end of it right? I will test this on Monday but I have seen some text editors automatically add a return when saving so want to quickly rule that out. |
No there is no new line. I have checked it few times. I have even added a new line once to check the result in the logs. It was than with extra new line. Looked like this: Also the same file is used and shared by the postgres container. It works well. When I run the postgres with secrets from files and n8n with normal explicit password and user in docker-compose file it works. |
Hey @bartoszrapp, Perfect, I have taken a look and managed to reproduce the issue. |
Hey @Joffcom, Thank you for the update. I hope this will be an easy fix and nothing serious that would require a lot of work :) |
Bug Description
When you try to deploy n8n with Postgres and you want to use secrets to safely pass the DB credentials is seems the \n is added at the end of content read from /run/secrets/.... resulting in authorization error. With user and password passed explicite using env variable everything works as expected.
n8n_postgres | 2024-09-14 16:52:27.159 UTC [68] FATAL: password authentication failed for user "n8n_db_user
n8n_postgres | "
n8n_postgres | 2024-09-14 16:52:27.159 UTC [68] DETAIL: Role "n8n_db_user
n8n_postgres | " does not exist.
n8n_postgres | Connection matched file "/var/lib/postgresql/data/pg_hba.conf" line 128: "host all all all scram-sha-256"
n8n_app | Error: There was an error initializing DB
n8n_app | DatabaseError: password authentication failed for user "n8n_db_user
n8n_app | "
To Reproduce
services:
n8n:
image: docker.n8n.io/n8nio/n8n
container_name: n8n_app
restart: always
ports:
- 9090:5678
environment:
- N8N_PROXY_HOPS=1
- N8N_SECURE_COOKIE=false
- N8N_PORT=5678
- N8N_PROTOCOL=https
- DB_TYPE=postgresdb
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER_FILE=/run/secrets/db_username
- DB_POSTGRESDB_PASSWORD_FILE=/run/secrets/db_password
volumes:
- n8n_data:/home/node/.n8n
- /home/docker/storage/n8n-local-files:/files
networks:
- proxy_bus_network
- internal_n8n
secrets:
- db_username
- db_password
depends_on:
postgres:
condition: service_started
postgres:
image: postgres:16
restart: always
container_name: n8n_postgres
environment:
- POSTGRES_DB=n8n
- POSTGRES_USER_FILE=/run/secrets/db_username
- POSTGRES_PASSWORD_FILE=/run/secrets/db_password
volumes:
- n8n_postgres_data:/var/lib/postgresql/data
networks:
- internal_n8n
secrets:
- db_username
- db_password
volumes:
n8n_data:
name: n8n_data
n8n_postgres_data:
name: n8n_postgres_data
networks:
proxy_bus_network:
name: proxy_bus_network
external: true
internal_n8n:
name: internal_n8n
secrets:
db_username:
file: ./db_username.txt
name: n8n_pg_username
db_password:
file: ./db_password.txt
name: n8n_pg_password
Expected behavior
Using DB_POSTGRESDB_USER_FILE and DB_POSTGRESDB_PASSWORD_FILE should work the same as using DB_POSTGRESDB_USER and DB_POSTGRESDB_PASSWORD
Operating System
Ubuntu Linux 24.04 LTS
n8n Version
1.58.2
Node.js Version
20.15.0
Database
PostgreSQL
Execution mode
main (default)
The text was updated successfully, but these errors were encountered: