haines/pg-aws_rds_iam

IAM Role not used during deployment

benebrice opened this issue ยท 5 comments

I'm using Capistrano 3 to deploy my app. Configuration when well during testing but on deploy, I got this error:

PG::ConnectionBad: connection to server at "X.X.X.X", port 1234 failed: FATAL:  PAM authentication failed for user "my_user" (PG::ConnectionBad)
connection to server at "X.X.X.X", port 1234 failed: FATAL:  pg_hba.conf rejects connection for host "Y.Y.Y.Y", user "my_user", database "my_db"

It's failing on step deploy:migrating but when I'm running it manually with

cap staging deploy:migrating there is not error. I'm a bit confused.

๐Ÿคฆ๐Ÿป Misconfiguration on my side. My bad!

haines commented

No problem, glad you got it sorted!

Actually I'm still have this issue randomly.. ๐Ÿค”
But only in production.

ActiveRecord::NoDatabaseError
connection to server at "X.X.X.X", port 5432 failed: FATAL:  PAM authentication failed for user "my_user" (ActiveRecord::NoDatabaseError)
connection to server at "X.X.X.X", port 5432 failed: FATAL:  pg_hba.conf rejects connection for host "X.X.X.X", user "my_user", database "my_db", no encryption

I did not understand the reason yet. It seems random. Do you have an idea @haines ?

haines commented

I've seen this before when the database instance is low on memory (#248 (comment)) - I would suggest checking the PostgreSQL error logs in the RDS console and maybe taking a look at your utilisation metrics?

This makes sense. It's a small RDS instance. Thanks for the help @haines!

Edit: I confirm, increasing the RDS instance type fixed this issue ๐Ÿ‘Œ๐Ÿป