2

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 ?

2
  • Can you log in to the command-line client with those credentials? Commented Feb 28, 2012 at 23:47
  • Did you Restart Postgresql server? See my answer Commented Feb 28, 2012 at 23:49

3 Answers 3

2

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

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

1 Comment

Find pg_hba.conf in /etc/postgresql/X.X/main (replace X.X with your release number) if you're running Debian server.
1

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

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

Comments

1

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

1 Comment

Same here, CentOS 6.6. Also, this file was owned by postgres, so I had become the postgres user to access it, ($ sudo su postgres).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.