nobody
nobody

Reputation: 1949

Rails postgresql DB connection fails

I'm very new to Ruby and postgres.

Below is my database.yml

development:
  adapter: postgresql
  database: test_database
  username: postgresql
  password: mypassword
  host: localhost
  encoding: utf8

The user exists and I'm, able to login using same credentials in phpPgadmin. But when I start rails server and go to home page of app, I get FATAL: Ident authentication failed for user "postgresql".

Edit: In case pghba.conf matters,

# TYPE  DATABASE          USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
#local    all             all                                     peer
local     all             postgres                                md5
local     all             postgresql                              md5

Could anyone please help ?

Upvotes: 2

Views: 2528

Answers (3)

Cramps
Cramps

Reputation: 464

For anyone who still can't find their pg_hba.conf file, I'm using PostgreSQL v9.2 and I found mine in:

/var/lib/pgsql/9.2/data/pg_hba.conf

Upvotes: 1

Zeel
Zeel

Reputation: 234

I can find my pg_hba.conf file in the path:

/etc/postgresql/8.4/main/pg_hba.conf

Upvotes: 1

AMIC MING
AMIC MING

Reputation: 6354

open PostgreSQL client authentication configuration file

vi /var/lib/pgsql/data/pg_hba.conf

This file manage below stuffs

  1. Which hosts are allowed to connect
  2. How clients are authenticated
  3. Which PostgreSQL user names they can use
  4. Which databases they can access

By default Postgresql uses IDENT-based authentication. All you have to do is allow username and password based authentication for your network or webserver. IDENT will never allow you to login via -U and -W options. Append following to allow login via localhost only:

local   all all         trust
host    all 127.0.0.1/32    trust

Save and close the file. Restart Postgresql server:

service postgresql restart   OR
sudo /etc/init.d/postgresql restart

It should work

Upvotes: 2

Related Questions