Open bartoszrapp opened 1 month ago
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: n8n_postgres | 2024-09-14 16:52:27.159 UTC [68] DETAIL: Role "n8n_db_user n8n_postgres | n8n_postgres | " does not exist.
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:
db_password depends_on: postgres: condition: service_started
postgres: image: postgres:16 restart: always container_name: n8n_postgres environment:
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)