3

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

1
  • Try removing the dot from password? Also, how do You create Your db? Have You actually set this password on psql? Commented Sep 21, 2017 at 2:30

3 Answers 3

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"

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

1

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

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.