Ident authentication failed for user “username” OR createdb: could not connect to database postgres: FATAL: Peer authentication failed for user “user_name”


Error#1

createdb: could not connect to database postgres: FATAL: Peer authentication failed for user “user_name”

OR

Error#2

Ident authentication failed for user “username”

Solution
Error Occured to me while runing

rake db:create

For postgres Database creation.

sudo find / -name pg_hba.conf
sudo gedit/etc/postgresql/8.4/main/pg_hba.conf

Content of pg_hba.conf file
Note: I replaced ident with md5 in first line.


# Database administrative login by UNIX sockets
local   all         postgres                          md5

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5
sudo service postgresql restart
Advertisements

I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: , , ,
Posted in postgres, Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

StackOverFlow
Categories
Archives
%d bloggers like this: