Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails Authentication Error for postgres

I have created Postgresql database locally. Postgre database

And here is my database.yml file. default: &default adapter: postgresql pool: 5 timeout: 5000

development:
  <<: *default
  database: myrubyblog
  username: postgres
  password: Naruto1994.

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: myrubyblog
  username: postgres
  password: Naruto1994.

production:
  <<: *default
  database: myrubyblog
  username: postgres
  password: Naruto1994.

I have made sure to enter correct password but I am still getting this error.

Error in the code

like image 405
Rajat Avatar asked Mar 07 '26 04:03

Rajat


1 Answers

Messages like this indicate that you contacted the server, and it is willing to talk to you, but not until you pass the authorization method specified in the pg_hba.conf file.

Try this:

// set new password for user "postgres"
$sudo su postgres -c 'psql --username=postgres'
ALTER USER postgres with encrypted password 'your_password';
//change pg_hba.conf
local all postgres md5

then restart postgres.

This article might help you: Postgresql: password authentication failed for user "postgres"

like image 147
kansiho Avatar answered Mar 08 '26 17:03

kansiho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!