Rails: FATAL: Password Authentication Failed For User Rails: FATAL: Password Authentication Failed For User postgresql postgresql

Rails: FATAL: Password Authentication Failed For User


  1. make you user superuser: ALTER USER user_name WITH SUPERUSER;

  2. edit the file pg_hba.conf : set method from md5 in trust

TYPE DATABASE USER ADDRESS METHOD

IPv4 local connections:host all all 127.0.0.1/32 trust

IPv6 local connections:host all all ::1/128 trust

...............................................................................


I had this issue when working on a Rails application with PostgreSQL database.

The database user already had Super admin rights and permissions to the database that I created, but I was still encountering this error:

F, [2020-10-23T08:04:06.031161 #8902] FATAL -- : [4229b10c-e16f-4f26-90cc-facd47b2088c] ActionView::Template::Error (FATAL:  password authentication failed for user "prod_user"FATAL:  password authentication failed for user "prod_user"

Here's how I fixed it:

The issue was that the Database Password for the prod_user specified for my Database environment variable was not correct in my .env file.

I had to modify it to into the correct one.

That's all.

I hope this helps


In my case, I found that a later host permissions rule line in the pg_hba.conf file had over-ridden the earlier local line. I was correctly configuring the local line to use md5 authentication but the host line was set to ident which I changed to md5

Note that using trust is an insecure method, so you shouldn't use it in any production-style deployment.