FATAL: password authentication failed for user "postgres"
Which chart: postgresql
Describe the bug
I cannot connect to the postgresql instance.
To Reproduce
I'm executing the following commands (exactly as mentioned in the description after helm install):
helm install postgresql bitnami/postgresql
export POSTGRES_PASSWORD=$(kubectl get secret --namespace default postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
Then neither this
kubectl run postgresql-client --rm --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:11.14.0-debian-10-r17 --env="PGPASSWORD=$POSTGRES_PASSWORD" --command -- psql --host postgresql -U postgres -d postgres -p 5432
nor this
kubectl port-forward --namespace default svc/postgresql 5432:5432 &
PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U postgres -d postgres -p 5432
is working
Expected behavior I expect to get connected.
Version of Helm and Kubernetes:
- Output of
helm version:
version.BuildInfo{Version:"v3.5.0", GitCommit:"32c22239423b3b4ba6706d450bd044baffdcf9e6", GitTreeState:"dirty", GoVersion:"go1.15.6"}
- Output of
kubectl version:
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:33:37Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"clean", BuildDate:"2021-10-27T18:35:25Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/amd64"}
Additional context Add any other context about the problem here.
pod logs
postgresql 12:52:51.77
postgresql 12:52:51.77 Welcome to the Bitnami postgresql container
postgresql 12:52:51.78 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
postgresql 12:52:51.78 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
postgresql 12:52:51.78
postgresql 12:52:51.80 INFO ==> ** Starting PostgreSQL setup **
postgresql 12:52:51.82 INFO ==> Validating settings in POSTGRESQL_* env vars..
postgresql 12:52:51.83 INFO ==> Loading custom pre-init scripts...
postgresql 12:52:51.84 INFO ==> Initializing PostgreSQL database...
postgresql 12:52:51.88 INFO ==> pg_hba.conf file not detected. Generating it...
postgresql 12:52:51.88 INFO ==> Generating local authentication configuration
postgresql 12:52:51.89 INFO ==> Deploying PostgreSQL with persisted data...
postgresql 12:52:51.90 INFO ==> Configuring replication parameters
postgresql 12:52:51.93 INFO ==> Configuring fsync
postgresql 12:52:51.98 INFO ==> Loading custom scripts...
postgresql 12:52:51.98 INFO ==> Enabling remote connections
postgresql 12:52:52.00 INFO ==> ** PostgreSQL setup finished! **
postgresql 12:52:52.02 INFO ==> ** Starting PostgreSQL **
2021-12-21 12:52:52.039 GMT [1] LOG: pgaudit extension initialized
2021-12-21 12:52:52.040 GMT [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2021-12-21 12:52:52.040 GMT [1] LOG: listening on IPv6 address "::", port 5432
2021-12-21 12:52:52.042 GMT [1] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2021-12-21 12:52:52.050 GMT [93] LOG: database system was shut down at 2021-12-21 12:51:15 GMT
2021-12-21 12:52:52.054 GMT [1] LOG: database system is ready to accept connections
2021-12-21 12:53:04.513 GMT [107] FATAL: password authentication failed for user "postgres"
2021-12-21 12:53:04.513 GMT [107] DETAIL: Password does not match for user "postgres".
Connection matched pg_hba.conf line 1: "host all all 0.0.0.0/0 md5"
I also tried to reset the password using --set (as described in the readme) but it didn't work either.
Anyway I think it should work flawlessly when using the helm after install description and it does not.
I've tried to install with version flag and it worked:
helm install postgresql2 --version 10.13.7 bitnami/postgresql
Hi,
Could you ensure that you are not reusing persistent volumes from other PostgreSQL installations? Make sure that there are no PostgreSQL PVCs because then the password will not match (it will be using a random-generated password from another installation).
Hi @javsalgar,
thank you for your answer.
well how do I make that sure? The only way I know of is changing the docker env using eval $(minikube -p tilt-remotify docker-env) and deleting the existing bitnami images.
ah so this has something todo with kubernetes persisten volumes... hmm. I'll dig into that
Ok so now it is working. Thank you @javsalgar for the hint about pv/c.
For anyone who will come across this issue make sure your pv/c are deleted by checking the following output for postgresql:
kubectl get pv
and
kubectl get pvc
Then if they are not needed anymore delete them using kubectl delete pv(c) <Name>
It's also mentioned in the docs :)
NOTE: Once this chart is deployed, it is not possible to change the application's access credentials, such as usernames or passwords, using Helm. To change these application credentials after deployment, delete any persistent volumes (PVs) used by the chart and re-deploy it, or use the application's built-in administrative tools if available.
I had the same problem, and I was sure I was using a new PV. Chart version is 11.1.26
Could you please create a separate ticket filling the issue template with your specific parameters? It will help us to reproduce the issue
I had the same problem, and I was sure I was using a new PV. Chart version is 11.1.26
Same here on an app chart i'm trying to upgrade to use 11.1.26. I get this error for both the postgres and custom user. @jiaxinonly did you create an issue yet?
@mcritchlow , in any case, you can create yours, and if it is the case, we can mark it as duplicated afterwards.
chart
bitnami/postgresql 11.1.26
To Reproduce
- Run the following command to install it
kubectl create ns database
helm -n database install postgresql bitnami/postgresql --version 11.1.26 --set global.storageClass=nfs-client --set global.postgresql.auth.postgresPassword=CZbCjPPs23FV

- Enter the container and try to connect
Another helm hint is wrong, /opt/bitnami/scripts/postgresql/entrypoint.sh is the right path
/opt/bitnami/scripts/postgresql/entrypoint.sh /bin/bash
psql

logs
2022-05-07 13:36:28.478 GMT [205] FATAL: password authentication failed for user "postgres"
2022-05-07 13:36:28.478 GMT [205] DETAIL: User "postgres" has no password assigned.
Connection matched pg_hba.conf line 1: "host all all 0.0.0.0/0 md5"
2022-05-07 13:36:28.583 GMT [213] FATAL: password authentication failed for user "postgres"
2022-05-07 13:36:28.583 GMT [213] DETAIL: User "postgres" has no password assigned.
Connection matched pg_hba.conf line 1: "host all all 0.0.0.0/0 md5"
2022-05-07 13:36:32.930 GMT [214] FATAL: password authentication failed for user "postgres"
2022-05-07 13:36:32.930 GMT [214] DETAIL: User "postgres" has no password assigned.
Connection matched pg_hba.conf line 1: "host all all 0.0.0.0/0 md5"
2022-05-07 13:36:38.480 GMT [222] FATAL: password authentication failed for user "postgres"
2022-05-07 13:36:38.480 GMT [222] DETAIL: User "postgres" has no password assigned.
Connection matched pg_hba.conf line 1: "host all all 0.0.0.0/0 md5"
2022-05-07 13:36:38.541 GMT [229] FATAL: password authentication failed for user "postgres"
2022-05-07 13:36:38.541 GMT [229] DETAIL: User "postgres" has no password assigned.
Connection matched pg_hba.conf line 1: "host all all 0.0.0.0/0 md5"
2022-05-07 13:36:48.497 GMT [237] FATAL: password authentication failed for user "postgres"
2022-05-07 13:36:48.497 GMT [237] DETAIL: User "postgres" has no password assigned.
helm version
version.BuildInfo{Version:"v3.8.2", GitCommit:"6e3701edea09e5d55a8ca2aae03a68917630e91b", GitTreeState:"clean", GoVersion:"go1.17.5"}
kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5", GitCommit:"c285e781331a3785a7f436042c65c5641ce8a9e9", GitTreeState:"clean", BuildDate:"2022-03-16T15:58:47Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.5", GitCommit:"c285e781331a3785a7f436042c65c5641ce8a9e9", GitTreeState:"clean", BuildDate:"2022-03-16T15:52:18Z", GoVersion:"go1.17.8", Compiler:"gc", Platform:"linux/amd64"}
I couldn't reproduce this problem in another cluster, and I'm sure it was an environmental issue. Even though I tried to keep the environment consistent, the installation failed.
Here's a solution You need to go into the container and execute the command
- Switch the user
/opt/bitnami/scripts/postgresql/entrypoint.sh /bin/bash
- Initialize another database
initdb -D /bitnami/postgresql/databak/
- Access the back-end storage and modify the file. I'm using NFS. On the NFS server, delete the data directory under the mount directory and rename databak as Data.
rm -rf data
mv databak data
- Remove the POD and let it automatically create a new pod
kubectl delete -n database pod postgresql-0
- After the new POD is ready, enter the container again to execute the command
/opt/bitnami/scripts/postgresql/entrypoint.sh /bin/bash
- Change the permission of PGSQL
cat > /opt/bitnami/postgresql/conf/pg_hba.conf << EOF
host all all 0.0.0.0/0 trust
host all all ::/0 trust
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
EOF
- Reload config
pg_ctl reload -D /bitnami/postgresql/data/
- Connecting to a Database
psql
- Example Change the password of postgres
ALTER USER postgres WITH PASSWORD 'CZbCjPPs23FV';
- Exit the connection
exit
- Restore permissions
cat > /opt/bitnami/postgresql/conf/pg_hba.conf << EOF
host all all 0.0.0.0/0 md5
host all all ::/0 md5
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
EOF
- Reload config
pg_ctl reload -D /bitnami/postgresql/data/
Your PostgresQL should now be working properly @mcritchlow
Hi, Thanks @jiaxinonly for providing help.
