PostgreSQL: password authentication failed for user

Everything was working fine. Then for no apparent reason PostgreSQL started failing with the error message:

FATAL:  password authentication failed for user


.pgpass had my user name along with postgres. Running this worked:

psql -U postgres -h localhost -p 5432

This failed:

psql -U my_username -h localhost -p 5432

This allowed me to manually enter the password and by pass .pgpass, but it still failed:

psql -U my_username -h localhost -p 5432 -W

This allowed me to list the users:

psql -c '\du' -U postgres

And that is how I discovered that my password had expired. I did not even know it could expire. I fixed it in pgadmin.

It’s Back…

So I had things working. I was do a lot of work using pg_restore. All of a sudden, password auth failed again. The above procedures were no help. In pgadmin I re-entered the password. Now its working again.