I'm having a problem with an elastic bean stalk setup on AWS linux 2. It's a laravel App with Postgres as the DB. Password auth failed for user


I have a laravel App on elastic beanstalk on AWS. And I am using Postgres as the DB. It is an AWS linux 2.

When I try connecting even local to the db I get this error.

I tried modifying the db’s inbound rules, still not working.

Illuminate\Database\QueryException: SQLSTATE[08006] [7] FATAL:
password authentication failed for user "postgres" FATAL: password
authentication failed for user "postgres" (SQL: select count(*) as
aggregate from "user" where "phoneNumber" = +1111111111111111) in file
on line 692


If your DB is a Managed PostgreSQL on AWS RDS

Then you may want to reset password of the postgres user.

As per RDS manual

To modify the master user password, follow these steps:

  1. Open the Amazon RDS console.
  2. Select Databases.
  3. Select the RDS DB instance, and then choose Modify.
    Note: If you use Aurora, expand the cluster, and choose the instance that you want to modify. Then, choose Modify.
  4. Enter the master user password you want to use in the New Master Password field.
    Note: The password change is asynchronous, and applies as soon as possible. This change ignores the Apply Immediately setting.
  5. Choose Continue, and then choose Modify DB Instance.

The Status field for your RDS DB instance on the RDS dashboard changes to resetting-master-credentials. When the modification is complete, the Status column changes to Available. You can also modify an RDS DB instance using the Amazon RDS API or the AWS Command Line Interface (AWS CLI).

If your DB is self-deployed to the AWS EC2 instance

Then you may want to enable password-based authentication of the postgres user. It’s disabled by default for new DB instances.

  1. Find the pg_hba.conf file
    To find the pg_hba.conf file on your server, you can look in the PostgreSQL configuration directory.
find /etc/postgresql/ -name pg_hba.conf
  1. Then open found file in your ${EDITOR}
  2. To allow md5 password authentication for any connections coming from the local network, add a line like this:
host      all         all    md5
  1. And then restart PostgreSQL:
sudo pgctl restart

Answered By – Yasen

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published