Ricardo Jacas
Ricardo Jacas

Reputation: 156

Rails/PostgreSQL problem: PG::ConnectionBad: fe_sendauth: no password supplied

I'm trying to run my tests for my app but I keep getting both this errors:

PG::ConnectionBad: fe_sendauth: no password supplied

PG::ConnectionBad: FATAL: sorry, too many clients already

I'be read all previous answers and it seems to be, for everybody else, either a missing password or a misconfiguration of the pg_hba.conf file.

This is how my database.yml looks like:

default: &default
  adapter: postgresql
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000
  encoding: utf8
  reconnect: true
  host: localhost
  username: postgres
  password: <password>

development:
  <<: *default
  database: <dev-db>
  host: <dev-host>
  username: <dev-user>
  password: <dev-pass>

test:
  <<: *default
  database: <test-db>

I already checked the pg_hba.conf config file and its configured to md5 for all entries listed.

Any clues to what might be the problem?

I'm running PostgreSQL 10, Rails 5.2.3 on Ruby 2.5.5, on a Macbook with Mojave.

Thanks in advance.

Upvotes: 0

Views: 519

Answers (1)

Allison
Allison

Reputation: 2336

Does your postgres user actually have a password set on it? Typically there is no password for the default postgres user, so this is something you would need to have gone out of your way to do; judging by the error message, it sounds like you are using the default posgres user and have not gone out of your way to set a password in the PostgreSQL CLI.

I suggest stripping it down to a very basic default, functional config like:

postgres: &postgres
  adapter: postgresql
  encoding: utf8
  pool: 5
development:
  <<: *postgres
  database: project_name_development
test:
  <<: *postgres
  database: project_name_test

Then incrementally add back additional configuration options one at a time, confirming that each one works before adding the next. Env vars also may not be available to database.yml depending on your project configuration and installed gems.

Upvotes: 0

Related Questions