0

I am using PostgreSQL-12 with ruby 2.7 & rails 6.0.3 on ubuntu desktop 20.04LTS

whenever I try to rails db:create i get the following error

FATAL: Peer authentication failed for user "postgres" Couldn't create the 'myap_development' database. Please check your configuration. rails aborted! ActiveRecord::NoDatabaseError: FATAL: Peer authentication failed for user "postgres"

i have been tweaking the methods in pg_hba.conf from peer to md5, trust, all to no avail my database.yml configuration is accurate too.

databse.yml

default: &default
  adapter: postgresql
  encoding: unicode
  username: postgres
  port: 5432
  password: postgres

  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: myap_development
bottles
  • 25
  • 7
  • 1
    have you run `sudo service postgresql restart` after `pg_hba.conf` change? Can you add your `database.yml`config here? – cmramseyer Jun 15 '20 at 05:27
  • i did run that code after that but did not do – bottles Jun 15 '20 at 13:54
  • try adding `host: localhost` to `database.yml`. – cmramseyer Jun 15 '20 at 14:27
  • i have added `host: localhost` but didn't do – bottles Jun 15 '20 at 15:05
  • even now when i try to enter **PostgreSQL console** like `sudo -u postgres psql` i get the following error `psql: error: could not connect to server: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?` – bottles Jun 15 '20 at 15:08
  • my bad. i had to start the database sever `sudo pg_ctlcluster 12 main start` – bottles Jun 15 '20 at 15:40

1 Answers1

0

Start database server

sudo pg_ctlcluster 12 main start
bottles
  • 25
  • 7