Explore Courses Blog Tutorials Interview Questions
0 votes
in SQL by (180 points)

When I was trying to make Postgres work with Rails.

I'm getting the below error:

FATAL: Peer authentication failed for user "postgres"

Here is the pg_hba.conf, my database.yml, and the dump of the full trace.

I tried changing the authentication to md5 in pg_hba and tried different things as well, but nothing seems to be working.

I have also created a new user and the database as per Rails 3.2, FATAL: Peer authentication failed for the user (PG::Error)

But it doesn't even show up on pgadmin or even when I run sudo -u postgres psql -l.

Any idea where I'm going wrong? 

1 Answer

0 votes
by (12.7k points)

Regarding this issue, you need to locate your pg_hba.conf. The command is:

find / -name 'pg_hba.conf' 2>/dev/null

and after that change the configuration file:

Postgresql 9.3

Postgresql 9.3

Postgresql 9.4

Postgresql 9.3

The next step is: Restarting your db instance:

service postgresql-9.3 restart

If you have any problems, you need to set the password again:

ALTER USER db_user with password 'db_password';

If you want to learn more about SQL, Check out this SQL Certification by Intellipaat. 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories