Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create user and database in linux server. I am able to create user with the following code:

su - postgres
# createuser -S -D -R myUser

but when I tried to create database with code :

# createdb -U myUser -p 5432 myDatabase

I get following error:

createdb: could not connect to database postgres: FATAL:  Ident authentication failed for user "myUser"

I am new to linux so I am unable to figure out why I was able to create user but while creating database there is connection error with postgres. And also error for ident authentication for user.

share|improve this question
up vote 1 down vote accepted

You need to learn more about HBA configuration.

There are some basic authentication methods:

  • trust - every users can connect to database(s) specified at second column where all means just all databases in cluster (yeah, excluding template0, because datallowconn in pg_database system catalog is set to false.. nevermind)
  • ident (prior to PostgreSQL 8.4 ident sameuser) - only actually logged (for example using su in console as your su - postgres) system user (with same name as role name) can connect
  • md5 - every user that knows role (PostgreSQL) password can log to database

Every time you attempting connection to concrete role and database even if do not write is explicitely.

The are generally two types of connection:

  • local - Unix-domain sockets
  • host - using TCP/IP connection

If you don't know which you are using, then it's local. To use TCP/IP connection you need to specify -h option with target IP where postmaster is listening. For example you can add -h localhost or -h, but check your listen_adresses (AFAIK default value is localhost, so it's ok) property in postgresql.conf and accepted client IP-address(es) in HBA.

share|improve this answer

you must add the auth setting on your


e.g: for localhost
host    all             all               ident

e.g: full conf:
local   all             all                                     ident
host    all             all               ident
host    all             myUser            ident

then reload the postgres

share|improve this answer
+1 Was about to post the same answer. – EdMelo May 12 '11 at 12:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.