-1

I am using a remote PostgreSQL on another server and want to deploy Rails app to AWS. I want the AWS to communicate with that remote PostgreSQL database server.

I'm getting the error:

FATAL: Peer authentication failed for user "postgres"

Although I've whitelisted the IP in pg_hba.conf

How I've whitelisted?

I've seen the Public IP in AWS Console and added that. I've pinged my AWS site and added that IP.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ninja Boy
  • 1,112
  • 3
  • 14
  • 28

1 Answers1

0

Peer authentication in the error means you're not trying to connect remotely, but locally. You must review the settings in database.yml. See PG Peer authentication failed for a related question.

Once you're ready to connect to the real remote server, that'll probably still won't work with the pg_hba.conf linked to in the comments because of:

host all all * md5
host all all [AWS-PINGED-IP] md5
host all all [AWS-SPECIFIED-PUBLIC-IP] md5

* is not accepted as an IP address mask, shell wildcards syntax is not welcome here. Use 0.0.0.0/0 in CIDR notation to mean "any IPv4 address". Or remove entirely this line if you didn't mean to accept connections from any address, which seems to be the case given the two lines after.

Note that rules interpretation stops at the first match in order of declaration, so it doesn't make sense to have an "accept-all" rule followed by a much more restrictive rule, as the latter will always be ignored.

Community
  • 1
  • 1
Daniel Vérité
  • 58,074
  • 15
  • 129
  • 156