Problem is while running integration tests, i receive this error:
error: password authentication failed for user "postgres"
at Connection.parseE (node_modules/pg/lib/connection.js:567:11)
at Connection.parseMessage (node_modules/pg/lib/connection.js:391:17)
This happens 100% of the time regardless of what is in the docker-compose.yml
file.
I'm using knex to make the DB connection like so:
function getConnectionForDatabase(database) {
return {
host: config.get("database.connection.host"),
user: config.get("database.connection.user"),
password: config.get("database.connection.password"),
database: database
};
}
function getDatabaseConnection(database) {
return knex({
client: config.get("database.client"),
connection: getConnectionForDatabase(database),
debug: config.get("database.debugMode"),
pool: {
min: config.get("database.pool.min"),
max: config.get("database.pool.max")
}
});
}
getDatabaseConnection("postgres");
host is 127.0.0.1 and lets say the username is postgres
and the password is postgres
the docker-compose.yml
contains:
postgres:
image: postgres:9.5.4
command: postgres -D /var/lib/postgresql/data
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: 'postgres'
POSTGRES_USER: 'postgres'
and i can connect to the postgres db manually using:
docker exec -it <hash> bash
root@<hash>:/# psql -U postgres
ive also updated the password to make the docker-compose.yml
file and it wont connect:
psql -d postgres -c "ALTER USER postgres WITH PASSWORD '<new password>';"
Yet, I run the unit test... i get the same error message as mentioned above!!
What am i missing to get this run? Any help would be incredibly appreciated!
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…