Docker PostgreSQL FATAL: password authentication failed for user “postgres”
Check if it is not the typos or cache
The normal procedure is to checking the typos in docker-compose.yml
Also most of us will try to force away the cache with 3 levels:
- Container level
- Volume level
2.1. In default docker location
2.2. In our directory / file mount
(configured in thedocker-compose.yml
) - Everything — System prune
docker container prune
docker volume prune
# if container prune not work
ls -la
# see if any physical mount to local directory
docker system prune
# try to blow everything away
Unfortunately, in some case the error does not go away
Unintentional Postgres already in the machine
Without knowing, it is common that you have PostgreSQL already install in your machine
So when you connect to port 5432
you connect to that Machine Postgres
You can do the quick check by
# Linux Based
systemctl status postgresql
# MacOS
brew services list
For Linux you can see the status of the service by status
command like below.
We see the villain here. Now stop it.
# Linux Based
sudo systemctl stop postgresql
# MacOS
brew services stop postgresql
Why we have this ?
Mostly when you install psql
command line you will install library like postgres
on apt
or brew
package manager.
The whole database is bundled in this package and ‘for convenient’ they will start the Postgres server to you.