No pg_hba.conf entry for host localhost (was: Re: createused + createdb problems with passwords) - Mailing list pgsql-general

From
Subject No pg_hba.conf entry for host localhost (was: Re: createused + createdb problems with passwords)
Date
Msg-id 20040324103713.8214.qmail@web12702.mail.yahoo.com
Whole thread Raw
Responses Re: No pg_hba.conf entry for host localhost (was: Re:
List pgsql-general
Hello,

Thank you - this morning I managed to create both a DB user and a DB.

However, I am still puzzled by this error that I am getting now:

[otis]$ psql MYDB
psql: FATAL:  No pg_hba.conf entry for host localhost, user otis,
database MYDB

On the other hand, "psql -h 127.0.0.1 MYDB" works!

Here is the relevant data:

# pg_hba.conf (entering 'localhost' instead of 127.0.0.1 doesn't work)
host    MYDB otis    127.0.0.1       255.255.255.0   md5

$ grep localhost /etc/hosts
127.0.0.1        localhost.localdomain localhost

$ hostname -i
MY.IP.IS.HERE (real, external IP, not 127....)


All I am trying to do is this:

- Don't allow external connections
  (got firewall, too, but multiple layers of security shouldn't hurt)
- Require even the local client to use username/password
  authentication with md5

Thanks,
Otis


--- "Nigel J. Andrews" <nandrews@investsystems.co.uk> wrote:
> On Tue, 23 Mar 2004 ogjunk-pg@yahoo.com wrote:
>
> > Hello,
> >
> > I have created PostgreSQL databases and users a number of times,
> but
> > I'm having trouble with that on a new server with Postgresql 7.3.4.
> >
> > I am trying to create a DB user (createuser) and a database itself
> > (createdb):
> >
> > bash-2.05b$ whoami
> > postgres
> >
> > bash-2.05b$ tail -5 ~postgres/data/pg_hba.conf
> > host    all     all     MY.IP.IS.HERE   255.255.255.255 md5
> >
> > bash-2.05b$ createuser -h MY.IP.IS.HERE otis
> > Shall the new user be allowed to create databases? (y/n) n
> > Shall the new user be allowed to create more new users? (y/n) n
> > Password:
> > psql: FATAL:  Password authentication failed for user "postgres"
> >
> > createuser: creation of user "otis" failed
> >
> > -- Question: what password am I supposed to enter here?
> > -- I suppose it's the postgres user's _DB_ password - but how do I
> know
> > what it is?  I didn't set it.
>
> Well you need to connect as a user with create user priviledges, i.e.
> a db
> superuser, in order to create your new user. If there isn't such a
> user you
> know the password for you'll have to ask the dba to do it for you.
>
> If you are the dba then you must already know the postgres password.
> If you
> have forgotten the password temporarily change md5 to trust in the
> pg_hba.conf
> file, restart the server and change the superusers password to a new
> one. Don't
> forget to restart the server after changing the pg_hba.conf entry
> back to md5.
>
> Alternatively, check that the localhost entry isn't already set to
> trust and
> just don't specify the server ip address for the commands. If it
> isn't set to
> trust already do the md5 --> trust --> md5 thing with that entry
> instead of the
> one above. (From the use of MY.IP.IS.HERE in your snippets I presume
> you are
> running these utilities on the same system as the server is running).
>
>
> >
> > bash-2.05b$ createdb -h MY.IP.IS.HERE simpydev
> > Password:
> > psql: FATAL:  Password authentication failed for user "postgres"
> >
> > createdb: database creation failed
> >
> > -- Question: what password am I supposed to enter here?
>
> Same as for createuser
>
> >
> >
> > Thank you,
> > Otis
>


pgsql-general by date:

Previous
From: Paolo Supino
Date:
Subject: unicode error and problem
Next
From: Dexter Tad-y
Date:
Subject: Re: No pg_hba.conf entry for host localhost (was: Re: