2

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

Rajat
  • 85
  • 2
  • 7
  • Try removing the dot from password? Also, how do You create Your db? Have You actually set this password on psql? – NeoVe Sep 21 '17 at 02:30

3 Answers3

3

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"

kansiho
  • 532
  • 4
  • 18
2

you may add localhost, and makesure if you have password with dot or no dot (Naruto1994), and my suggestion split database name between each environment (development, test and production)

development:
  adapter: postgresql
  encoding: unicode
  database: myrubyblog_development
  host: localhost
  username: postgres
  password: Naruto1994.  
  pool: 5

test: 
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: myrubyblog_test
  username: postgres
  password: Naruto1994.  
  pool: 5

production:
  adapter: postgresql
  encoding: unicode
  database: myrubyblog_production
  pool: 5
  host: localhost
  username: #env_variable
  password: #env_variable
widjajayd
  • 6,090
  • 4
  • 30
  • 41
1

You just need to add host: localhost to each env. e.g.

development:
  <<: *default
  database: myrubyblog
  host: localhost
  username: postgres
  password: Naruto1994.
Oscar Luza
  • 384
  • 3
  • 14