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

WTF???

.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.

Tastypie: the missing manual

I am using tastypie to try and get a REST interface working on a Django site. The API needs to be password protected. The problem is the docs assume you already know how authorize thru REST.

It’s actually trivial once you realize that the phrase “basic authentication” is actually a single entity; “basic-authentication” . Doing basic-authentication is pretty easy using the the python package “requests“. Just jump to the section in their docs. As easy as falling off a log.