Re: jdbc pg_hba.conf error

Lists: pgsql-general
From: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
To: jdbc <pgsql-odbc-owner(at)postgresql(dot)org>, pgsql_general <pgsql-general(at)postgresql(dot)org>
Subject: jdbc pg_hba.conf error
Date: 2007-05-30 11:36:11
Message-ID: 465D61AB.6000902@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,

I'm a newbee to postgreSQL. Does anyone know what this error means.
I'm trying to run the following java program. I have also included the
java program and the pg_hba.conf file.

java db_connect_pgsql.class

Checking if Driver is registered with DriverManager

Registered the driver ok, making DB connection now

Couldn't connect: print out a stack trace and exit.
org.postgresql.util.PSQLException: A connection error has occurred:
org.postgres ql.util.PSQLException:
FATAL: no pg_hba.conf entry for host "127.0.0.1", user
"b rakesh", database "testing123", SSL off

at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV3(Abstrac
tJdbc1Connection.java:337)
at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJ
dbc1Connection.java:214)
at org.postgresql.Driver.connect(Driver.java:139)
at java.sql.DriverManager.getConnection(DriverManager.java:559)
at java.sql.DriverManager.getConnection(DriverManager.java:189)
at db_connect_pgsql.main(db_connect_pgsql.java:25)

Here is my pg_.conf file

# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the PostgreSQL Administrator's Guide, chapter "Client
# Authentication" for a complete description. A short synopsis
# follows.
#
# This file controls: which hosts are allowed to connect, how clients
# are authenticated, which PostgreSQL user names they can use, which
# databases they can access. Records take one of seven forms:
#
# local DATABASE USER METHOD [OPTION]
# host DATABASE USER IP-ADDRESS IP-MASK METHOD [OPTION]
# hostssl DATABASE USER IP-ADDRESS IP-MASK METHOD [OPTION]
# hostnossl DATABASE USER IP-ADDRESS IP-MASK METHOD [OPTION]
# host DATABASE USER IP-ADDRESS/CIDR-MASK METHOD [OPTION]
# hostssl DATABASE USER IP-ADDRESS/CIDR-MASK METHOD [OPTION]
# hostnossl DATABASE USER IP-ADDRESS/CIDR-MASK METHOD [OPTION]
#
# (The uppercase quantities should be replaced by actual values.)
# The first field is the connection type: "local" is a Unix-domain socket,
# "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an
# SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket.
DATABASE can be "all", "sameuser", "samegroup", a database name (or
# a comma-separated list thereof), or a file name prefixed with "@".
# USER can be "all", an actual user name or a group name prefixed with
# "+" or a list containing either. IP-ADDRESS and IP-MASK specify the
# set of hosts the record matches. CIDR-MASK is an integer between 0
# and 32 (IPv4) or 128 (IPv6) inclusive, that specifies the number of
# significant bits in the mask, so an IPv4 CIDR-MASK of 8 is equivalent
# to an IP-MASK of 255.0.0.0, and an IPv6 CIDR-MASK of 64 is equivalent
# to an IP-MASK of ffff:ffff:ffff:ffff::. METHOD can be "trust", "reject",
# "md5", "crypt", "password", "krb4", "krb5", "ident", or "pam". Note
# that "password" uses clear-text passwords; "md5" is preferred for
# encrypted passwords. OPTION is the ident map or the name of the PAM
# service.
#
# This file is read on server startup and when the postmaster receives
# a SIGHUP signal. If you edit the file on a running system, you have
# to SIGHUP the postmaster for the changes to take effect, or use
# "pg_ctl reload".

# Put your actual configuration here
# ----------------------------------
#
# CAUTION: The default configuration allows any local user to connect
# using any PostgreSQL user name, including the superuser, over either
# Unix-domain sockets or TCP/IP. If you are on a multiple-user
# machine, the default configuration is probably too liberal for you.
# Change it to use something other than "trust" authentication.
#
# If you want to allow non-local connections, you need to add more
# "host" records. Also, remember TCP/IP connections are only enabled
# if you enable "tcpip_socket" in postgresql.conf.

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

# IPv4-style local connections:
#host all all 127.0.0.1 255.255.255.255 trust
# IPv6-style local connections:
#host all all ::1
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff trust

# Using sockets credentials for improved security. Not available everywhere,
# but works on Linux, *BSD (and probably some others)

local all all ident sameuser

______________________________________________________________________

Here is my java program that trying to make the connection

import java.sql.*;

public class db_connect_pgsql
{
public static void main(String[] args)
{
System.out.println("Checking if Driver is registered with
DriverManager\n");
//load the driver
try
{
Class.forName("org.postgresql.Driver");
}
catch(ClassNotFoundException cnfe)
{
System.err.println(cnfe);
System.out.println("Let's print a stack trace, and exit.");
cnfe.printStackTrace();
System.exit(1);
}
System.out.println("Registered the driver ok, making DB
connection now\n");
Connection dbConn = null;
try
{
dbConn =
DriverManager.getConnection("jdbc:postgresql://localhost/testing123","brakesh","");
}
catch(SQLException sqle)
{
System.out.println("Couldn't connect: print out a stack trace
and exit.");
sqle.printStackTrace();
System.exit(1);
}

if(dbConn != null)
System.out.println("Hooray! We connected to the database!");
else
System.out.println("We should never get here.");
}
}


From: Richard Huxton <dev(at)archonet(dot)com>
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: jdbc <pgsql-odbc-owner(at)postgresql(dot)org>, pgsql_general <pgsql-general(at)postgresql(dot)org>
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 11:42:59
Message-ID: 465D6343.60000@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Bhavana.Rakesh wrote:
> Hi,
>
> I'm a newbee to postgreSQL. Does anyone know what this error means.

> Couldn't connect: print out a stack trace and exit.
> org.postgresql.util.PSQLException: A connection error has occurred:
> org.postgres ql.util.PSQLException:
> FATAL: no pg_hba.conf entry for host "127.0.0.1", user
> "b rakesh", database "testing123", SSL
> off

It means exactly what it says - you have no entry in your pg_hba.conf
for host "127.0.0.1"

> Here is my pg_.conf file
[snip lots of commented-out lines]
> # Using sockets credentials for improved security. Not available
> everywhere,
> # but works on Linux, *BSD (and probably some others)
>
> local all all ident sameuser

This is the only uncommented line. Try uncommenting the line for
127.0.0.1 or adding your own if you don't want "trust" security.
--
Richard Huxton
Archonet Ltd


From: Devrim GÜNDÜZ <devrim(at)CommandPrompt(dot)com>
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: pgsql_general <pgsql-general(at)postgresql(dot)org>
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 11:48:16
Message-ID: 1180525696.3396.10.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello,

On Wed, 2007-05-30 at 07:36 -0400, Bhavana.Rakesh wrote:
> Here is my pg_.conf file
<snip>

Uncomment this line:

#host all all 127.0.0.1 255.255.255.255
trust

and reload PostgreSQL. And make sure that you read this part of the
manual:

http://www.postgresql.org/docs/current/static/client-authentication.html

Regards,
--
Devrim GÜNDÜZ
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, ODBCng - http://www.commandprompt.com/


From: Richard Huxton <dev(at)archonet(dot)com>
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 11:56:32
Message-ID: 465D6670.8070008@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

1. Please don't forget to cc: the list
2. Please don't top-quote

Bhavana.Rakesh wrote:
> Does this mean the pg_hba.conf file has to be edited everytime a new
> database/schema is created?

No, only when you want to change network access permissions for the
installation as a whole. See the manuals for full details.

Of course, if you have different rules for each database you'll need to
make more changes than if you have two or three rules that apply to a
whole installation.

With 8.2 you can control access to databases via ROLEs as well as access
to schemas,tables etc.

--
Richard Huxton
Archonet Ltd


From: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
To: Devrim GÜNDÜZ <devrim(at)CommandPrompt(dot)com>
Cc: pgsql_general <pgsql-general(at)postgresql(dot)org>
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 15:47:48
Message-ID: 465D9CA4.8060203@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello,
I'm still getting the error

[brakesh(at)lnx383 ~/db_connect]$ java db_connect_pgsql.class
Checking if Driver is registered with DriverManager

Registered the driver ok, making DB connection now

Couldn't connect: print out a stack trace and exit.
org.postgresql.util.PSQLException: A connection error has occurred:
org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host
"127.0.0.1", user "brakesh", database "testing123", SSL off

at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV3(AbstractJdbc1Connection.java:337)
at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:214)
at org.postgresql.Driver.connect(Driver.java:139)
at java.sql.DriverManager.getConnection(DriverManager.java:559)
at java.sql.DriverManager.getConnection(DriverManager.java:189)
at db_connect_pgsql.main(db_connect_pgsql.java:25)

Here is my updated version of pg_hba.conf file
__________________________________________________________________________
#
# If you want to allow non-local connections, you need to add more
# "host" records. Also, remember TCP/IP connections are only enabled
# if you enable "tcpip_socket" in postgresql.conf.

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host all all trust

# IPv4-style local connections:
host all all 127.0.0.1 255.255.255.255 trust
host testing123 brakesh 127.0.0.1 255.255.255.255 trust
# IPv6-style local connections:
#host all all ::1/128
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff trust

# Using sockets credentials for improved security. Not available everywhere,
# but works on Linux, *BSD (and probably some others)

#local all all ident sameuser

#Allow any user from any host with IP address 192.168.93.x to
# connect to database "template1" as the same username that ident on that
# host identifies him as (typically his Unix username):
#
#TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host testing123 all 140.90.193.238 255.255.255.0 ident sameuser


From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 16:00:11
Message-ID: 1180540811.15764.88.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, 2007-05-30 at 11:47 -0400, Bhavana.Rakesh wrote:
> Hello,
> I'm still getting the error

...

> Here is my updated version of pg_hba.conf file
> __________________________________________________________________________
> #
> # TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
> host all all trust

That line is missing the IP-address and IP-mask parameters. It looks as
if the first word should be "local" rather than "host", in which case it
would be valid.

Using this pg_hba.conf ought to give you the message:
FATAL: missing or erroneous pg_hba.conf file
if you try to connect from psql. I don't know if the Java stuff somehow
manages to bypass it or if you haven't done a kill -SIGHUP of the
postmaster to reload the configuration.

--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
Do you want to know God? http://www.lfix.co.uk/knowing_god.html


From: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>, pgsql_general <pgsql-general(at)postgresql(dot)org>, jdbc <pgsql-odbc-owner(at)postgresql(dot)org>
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 16:11:31
Message-ID: 465DA233.4030607@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

I used the example in the following URL

http://www.postgresql.org/docs/7.3/static/client-authentication.html

Thanks for the catch on "host" instead of "local". I made that change,
and reloaded pgsql.. But I still get the same error. I can connect to
the database using psql client, but my java connection seems to be failing.

Oliver Elphick wrote:
> On Wed, 2007-05-30 at 11:47 -0400, Bhavana.Rakesh wrote:
>
>> Hello,
>> I'm still getting the error
>>
>
> ...
>
>
>> Here is my updated version of pg_hba.conf file
>> __________________________________________________________________________
>> #
>> # TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
>> host all all trust
>>
>
> That line is missing the IP-address and IP-mask parameters. It looks as
> if the first word should be "local" rather than "host", in which case it
> would be valid.
>
> Using this pg_hba.conf ought to give you the message:
> FATAL: missing or erroneous pg_hba.conf file
> if you try to connect from psql. I don't know if the Java stuff somehow
> manages to bypass it or if you haven't done a kill -SIGHUP of the
> postmaster to reload the configuration.
>
>


From: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>, pgsql_general <pgsql-general(at)postgresql(dot)org>, jdbc <pgsql-odbc-owner(at)postgresql(dot)org>
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 16:30:38
Message-ID: 465DA6AE.7030904@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Oliver,

When I do a :
psql -p 5000 testing123
I can make a connection. However, when I do a

psql -U brakesh -h 127.0.0.1 -d testing123

I get the followign error:

psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh", database "testing123", SSL off

Oliver Elphick wrote:
> On Wed, 2007-05-30 at 12:11 -0400, Bhavana.Rakesh wrote:
>
>> I used the example in the following URL
>>
>> http://www.postgresql.org/docs/7.3/static/client-authentication.html
>>
>
> That does have local rather than host, of course.
>
> Are you using PostgreSQL 7,3 as well?
>
>
>> Thanks for the catch on "host" instead of "local". I made that
>> change, and reloaded pgsql.. But I still get the same error. I can
>> connect to the database using psql client, but my java connection
>> seems to be failing.
>>
>
> Were you using the exact same parameters for psql?
>
> psql -U brakesh -h 127.0.0.1 -d testing123
>
>


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>, pgsql_general <pgsql-general(at)postgresql(dot)org>, jdbc <pgsql-odbc-owner(at)postgresql(dot)org>
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 16:35:20
Message-ID: 20070530163520.GB18387@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, May 30, 2007 at 12:30:38PM -0400, Bhavana.Rakesh wrote:
> Oliver,
>
> When I do a :
> psql -p 5000 testing123
> I can make a connection. However, when I do a
>
> psql -U brakesh -h 127.0.0.1 -d testing123
>
> I get the followign error:
>
> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
> database "testing123", SSL off

Ofcourse, the first connection is a local connection, which you
obviously have configured. The latter connects to localhost, which you
havn't configured.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: pgsql_general <pgsql-general(at)postgresql(dot)org>
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 16:41:14
Message-ID: 1180543274.15764.102.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, 2007-05-30 at 12:30 -0400, Bhavana.Rakesh wrote:
> Oliver,
>
> When I do a :
> psql -p 5000 testing123
> I can make a connection.

Since you aren't specifying a host (with -h), that command uses a Unix
socket connection and only looks at lines in pg_hba.conf that begin with
"local".

(If you want to do the same in JDBC, make the hostname value blank.)

> However, when I do a
> psql -U brakesh -h 127.0.0.1 -d testing123
>
> I get the followign error:
>
> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user
> "brakesh", database "testing123", SSL off

What happens if you change "host" to "hostnossl" in pg_hba.conf?
(Seeing that that error message specifies that SSL is off.)
Please remember to SIGHUP or restart the postmaster after changing it.

Again, which version of PostgreSQL is this?

>
> Oliver Elphick wrote:
> > On Wed, 2007-05-30 at 12:11 -0400, Bhavana.Rakesh wrote:
> >
> > > I used the example in the following URL
> > >
> > > http://www.postgresql.org/docs/7.3/static/client-authentication.html
> > >
> >
> > That does have local rather than host, of course.
> >
> > Are you using PostgreSQL 7,3 as well?
> >
> >
> > > Thanks for the catch on "host" instead of "local". I made that
> > > change, and reloaded pgsql.. But I still get the same error. I can
> > > connect to the database using psql client, but my java connection
> > > seems to be failing.
> > >
> >
> > Were you using the exact same parameters for psql?
> >
> > psql -U brakesh -h 127.0.0.1 -d testing123
> >
> >
--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
Do you want to know God? http://www.lfix.co.uk/knowing_god.html


From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 16:46:59
Message-ID: 1180543619.15764.108.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, 2007-05-30 at 18:35 +0200, Martijn van Oosterhout wrote:
> On Wed, May 30, 2007 at 12:30:38PM -0400, Bhavana.Rakesh wrote:
> > Oliver,
> >
> > When I do a :
> > psql -p 5000 testing123
> > I can make a connection. However, when I do a
> >
> > psql -U brakesh -h 127.0.0.1 -d testing123
> >
> > I get the followign error:
> >
> > psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
> > database "testing123", SSL off
>
> Ofcourse, the first connection is a local connection, which you
> obviously have configured. The latter connects to localhost, which you
> havn't configured.

His original message (which I snipped) said he had:

# IPv4-style local connections:
host all all 127.0.0.1 255.255.255.255 trust
host testing123 brakesh 127.0.0.1 255.255.255.255 trust

So it seems to me he did have it configured.

In fact the first host line should be used and the second one for user
brakesh is redundant, since it comes later in the file. The only thing
I can see is that it might be related to SSL.

--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
Do you want to know God? http://www.lfix.co.uk/knowing_god.html


From: gonzales(at)linuxlouis(dot)net
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 17:00:16
Message-ID: Pine.LNX.4.64.0705301300070.28153@mx1.linuxlouis.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Did you grant access to your user?

On Wed, 30 May 2007, Oliver Elphick wrote:

> On Wed, 2007-05-30 at 18:35 +0200, Martijn van Oosterhout wrote:
>> On Wed, May 30, 2007 at 12:30:38PM -0400, Bhavana.Rakesh wrote:
>>> Oliver,
>>>
>>> When I do a :
>>> psql -p 5000 testing123
>>> I can make a connection. However, when I do a
>>>
>>> psql -U brakesh -h 127.0.0.1 -d testing123
>>>
>>> I get the followign error:
>>>
>>> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
>>> database "testing123", SSL off
>>
>> Ofcourse, the first connection is a local connection, which you
>> obviously have configured. The latter connects to localhost, which you
>> havn't configured.
>
> His original message (which I snipped) said he had:
>
> # IPv4-style local connections:
> host all all 127.0.0.1 255.255.255.255 trust
> host testing123 brakesh 127.0.0.1 255.255.255.255 trust
>
> So it seems to me he did have it configured.
>
> In fact the first host line should be used and the second one for user
> brakesh is redundant, since it comes later in the file. The only thing
> I can see is that it might be related to SSL.
>
>
>

--
Louis Gonzales
louis(dot)gonzales(at)linuxlouis(dot)net
http://www.linuxlouis.net


From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: gonzales(at)linuxlouis(dot)net
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 17:03:10
Message-ID: 1180544590.15764.120.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, 2007-05-30 at 13:00 -0400, gonzales(at)linuxlouis(dot)net wrote:
> Did you grant access to your user?

If you mean grant access by an SQL GRANT, he hasn't got far enough to
check that. The error specifically says "no pg_hba.conf entry". As far
as I can see, his pg_hba.conf is OK.

>
> On Wed, 30 May 2007, Oliver Elphick wrote:
>
> > On Wed, 2007-05-30 at 18:35 +0200, Martijn van Oosterhout wrote:
> >> On Wed, May 30, 2007 at 12:30:38PM -0400, Bhavana.Rakesh wrote:
> >>> Oliver,
> >>>
> >>> When I do a :
> >>> psql -p 5000 testing123
> >>> I can make a connection. However, when I do a
> >>>
> >>> psql -U brakesh -h 127.0.0.1 -d testing123
> >>>
> >>> I get the followign error:
> >>>
> >>> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
> >>> database "testing123", SSL off
> >>
> >> Ofcourse, the first connection is a local connection, which you
> >> obviously have configured. The latter connects to localhost, which you
> >> havn't configured.
> >
> > His original message (which I snipped) said he had:
> >
> > # IPv4-style local connections:
> > host all all 127.0.0.1 255.255.255.255 trust
> > host testing123 brakesh 127.0.0.1 255.255.255.255 trust
> >
> > So it seems to me he did have it configured.
> >
> > In fact the first host line should be used and the second one for user
> > brakesh is redundant, since it comes later in the file. The only thing
> > I can see is that it might be related to SSL.
> >
> >
> >
>
--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
Do you want to know God? http://www.lfix.co.uk/knowing_god.html


From: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 17:08:54
Message-ID: 465DAFA6.1030704@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

I'm using version 7.4. The "hostnossl" is not helping either. My error is

[brakesh(at)lnx383 ~]$ psql -U brakesh -h 127.0.0.1 -d testing123
psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
database "testing123", SSL off

The current pg_hba.conf file is as follows:

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
local all all trust

# IPv4-style local connections:
#host all all 127.0.0.1 255.255.255.255 trust
hostnossl all all 127.0.0.1 255.255.255.255 trust
hostnossl testing123 brakesh 127.0.0.1
255.255.255.255 trust
# IPv6-style local connections:
#host all all ::1/128
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff trust

# Using sockets credentials for improved security. Not available everywhere,
# but works on Linux, *BSD (and probably some others)

#local all all ident sameuser

#Allow any user from any host with IP address 192.168.93.x to
# connect to database "template1" as the same username that ident on that
# host identifies him as (typically his Unix username):
#
#TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
hostnossl testing123 all 140.90.193.238 255.255.255.0 ident
sameuser

Oliver Elphick wrote:
> On Wed, 2007-05-30 at 18:35 +0200, Martijn van Oosterhout wrote:
>
>> On Wed, May 30, 2007 at 12:30:38PM -0400, Bhavana.Rakesh wrote:
>>
>>> Oliver,
>>>
>>> When I do a :
>>> psql -p 5000 testing123
>>> I can make a connection. However, when I do a
>>>
>>> psql -U brakesh -h 127.0.0.1 -d testing123
>>>
>>> I get the followign error:
>>>
>>> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
>>> database "testing123", SSL off
>>>
>> Ofcourse, the first connection is a local connection, which you
>> obviously have configured. The latter connects to localhost, which you
>> havn't configured.
>>
>
> His original message (which I snipped) said he had:
>
> # IPv4-style local connections:
> host all all 127.0.0.1 255.255.255.255 trust
> host testing123 brakesh 127.0.0.1 255.255.255.255 trust
>
> So it seems to me he did have it configured.
>
> In fact the first host line should be used and the second one for user
> brakesh is redundant, since it comes later in the file. The only thing
> I can see is that it might be related to SSL.
>
>
>


From: gonzales(at)linuxlouis(dot)net
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 17:13:56
Message-ID: Pine.LNX.4.64.0705301309490.28271@mx1.linuxlouis.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

As super-user (postgres) you have to create the user in Postgres, then
Grant access. In other words, if the pg_hba.conf file specifies a user
who does not exist, "user brakesh does not exist" will cause a failure to
connect as well.

Every connection to a database, has to have a user associated with the
session.

So the fact that he has connected to at least one database, means he's
gotten far enough to connect and create the proper ID/Authentication.

Actually, I wonder if 'after' he's changed the pg_hba.conf file if he's
been restarting the postgres process? Which is 'session' associated.

Everytime you change the pg_hba.conf file, you have to restart postgres,
don't you?

On Wed, 30 May 2007, Oliver Elphick wrote:

> On Wed, 2007-05-30 at 13:00 -0400, gonzales(at)linuxlouis(dot)net wrote:
>> Did you grant access to your user?
>
> If you mean grant access by an SQL GRANT, he hasn't got far enough to
> check that. The error specifically says "no pg_hba.conf entry". As far
> as I can see, his pg_hba.conf is OK.
>
>>
>> On Wed, 30 May 2007, Oliver Elphick wrote:
>>
>>> On Wed, 2007-05-30 at 18:35 +0200, Martijn van Oosterhout wrote:
>>>> On Wed, May 30, 2007 at 12:30:38PM -0400, Bhavana.Rakesh wrote:
>>>>> Oliver,
>>>>>
>>>>> When I do a :
>>>>> psql -p 5000 testing123
>>>>> I can make a connection. However, when I do a
>>>>>
>>>>> psql -U brakesh -h 127.0.0.1 -d testing123
>>>>>
>>>>> I get the followign error:
>>>>>
>>>>> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
>>>>> database "testing123", SSL off
>>>>
>>>> Ofcourse, the first connection is a local connection, which you
>>>> obviously have configured. The latter connects to localhost, which you
>>>> havn't configured.
>>>
>>> His original message (which I snipped) said he had:
>>>
>>> # IPv4-style local connections:
>>> host all all 127.0.0.1 255.255.255.255 trust
>>> host testing123 brakesh 127.0.0.1 255.255.255.255 trust
>>>
>>> So it seems to me he did have it configured.
>>>
>>> In fact the first host line should be used and the second one for user
>>> brakesh is redundant, since it comes later in the file. The only thing
>>> I can see is that it might be related to SSL.
>>>
>>>
>>>
>>
>

--
Louis Gonzales
louis(dot)gonzales(at)linuxlouis(dot)net
http://www.linuxlouis.net


From: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
To: gonzales(at)linuxlouis(dot)net
Cc: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 17:21:02
Message-ID: 465DB27E.9040001@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Yes, I have been restarting the postgres every time I make changes to
the pg_hba.conf file.

-Bhavana
On a lighter note, it's a 'she' not 'he'. :) No offense taken. :))

gonzales(at)linuxlouis(dot)net wrote:
> As super-user (postgres) you have to create the user in Postgres, then
> Grant access. In other words, if the pg_hba.conf file specifies a
> user who does not exist, "user brakesh does not exist" will cause a
> failure to connect as well.
>
> Every connection to a database, has to have a user associated with the
> session.
>
> So the fact that he has connected to at least one database, means he's
> gotten far enough to connect and create the proper ID/Authentication.
>
> Actually, I wonder if 'after' he's changed the pg_hba.conf file if
> he's been restarting the postgres process? Which is 'session'
> associated.
>
> Everytime you change the pg_hba.conf file, you have to restart
> postgres, don't you?
>
>
>
> On Wed, 30 May 2007, Oliver Elphick wrote:
>
>> On Wed, 2007-05-30 at 13:00 -0400, gonzales(at)linuxlouis(dot)net wrote:
>>> Did you grant access to your user?
>>
>> If you mean grant access by an SQL GRANT, he hasn't got far enough to
>> check that. The error specifically says "no pg_hba.conf entry". As far
>> as I can see, his pg_hba.conf is OK.
>>
>>>
>>> On Wed, 30 May 2007, Oliver Elphick wrote:
>>>
>>>> On Wed, 2007-05-30 at 18:35 +0200, Martijn van Oosterhout wrote:
>>>>> On Wed, May 30, 2007 at 12:30:38PM -0400, Bhavana.Rakesh wrote:
>>>>>> Oliver,
>>>>>>
>>>>>> When I do a :
>>>>>> psql -p 5000 testing123
>>>>>> I can make a connection. However, when I do a
>>>>>>
>>>>>> psql -U brakesh -h 127.0.0.1 -d testing123
>>>>>>
>>>>>> I get the followign error:
>>>>>>
>>>>>> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user
>>>>>> "brakesh",
>>>>>> database "testing123", SSL off
>>>>>
>>>>> Ofcourse, the first connection is a local connection, which you
>>>>> obviously have configured. The latter connects to localhost, which
>>>>> you
>>>>> havn't configured.
>>>>
>>>> His original message (which I snipped) said he had:
>>>>
>>>> # IPv4-style local connections:
>>>> host all all 127.0.0.1 255.255.255.255
>>>> trust
>>>> host testing123 brakesh 127.0.0.1 255.255.255.255
>>>> trust
>>>>
>>>> So it seems to me he did have it configured.
>>>>
>>>> In fact the first host line should be used and the second one for user
>>>> brakesh is redundant, since it comes later in the file. The only
>>>> thing
>>>> I can see is that it might be related to SSL.
>>>>
>>>>
>>>>
>>>
>>
>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org, "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 17:28:18
Message-ID: 5646.1180546098@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Oliver Elphick <olly(at)lfix(dot)co(dot)uk> writes:
> His original message (which I snipped) said he had:

> # IPv4-style local connections:
> host all all 127.0.0.1 255.255.255.255 trust
> host testing123 brakesh 127.0.0.1 255.255.255.255 trust

> So it seems to me he did have it configured.

I've seen similar problems resolved by discovering that (1) the DBA
was editing the wrong copy of the pg_hba.conf file, or (2) there was
actually more than one postmaster running on the machine.

Check "ps" for multiple postmasters. Put a deliberate error in the
pg_hba.conf file and verify that the postmaster fails to restart.

regards, tom lane


From: gonzales(at)linuxlouis(dot)net
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-30 17:29:49
Message-ID: Pine.LNX.4.64.0705301328550.28271@mx1.linuxlouis.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Did you ever "createuser brakesh" ???

Apologies about the he,she ;)... he + s = she, see you're greater of a
person than a 'he.' Heehee.

On Wed, 30 May 2007, Bhavana.Rakesh wrote:

> Yes, I have been restarting the postgres every time I make changes to the
> pg_hba.conf file.
>
> -Bhavana
> On a lighter note, it's a 'she' not 'he'. :) No offense taken. :))
>
> gonzales(at)linuxlouis(dot)net wrote:
>> As super-user (postgres) you have to create the user in Postgres, then
>> Grant access. In other words, if the pg_hba.conf file specifies a user who
>> does not exist, "user brakesh does not exist" will cause a failure to
>> connect as well.
>>
>> Every connection to a database, has to have a user associated with the
>> session.
>>
>> So the fact that he has connected to at least one database, means he's
>> gotten far enough to connect and create the proper ID/Authentication.
>>
>> Actually, I wonder if 'after' he's changed the pg_hba.conf file if he's
>> been restarting the postgres process? Which is 'session' associated.
>>
>> Everytime you change the pg_hba.conf file, you have to restart postgres,
>> don't you?
>>
>>
>>
>> On Wed, 30 May 2007, Oliver Elphick wrote:
>>
>>> On Wed, 2007-05-30 at 13:00 -0400, gonzales(at)linuxlouis(dot)net wrote:
>>>> Did you grant access to your user?
>>>
>>> If you mean grant access by an SQL GRANT, he hasn't got far enough to
>>> check that. The error specifically says "no pg_hba.conf entry". As far
>>> as I can see, his pg_hba.conf is OK.
>>>
>>>>
>>>> On Wed, 30 May 2007, Oliver Elphick wrote:
>>>>
>>>>> On Wed, 2007-05-30 at 18:35 +0200, Martijn van Oosterhout wrote:
>>>>>> On Wed, May 30, 2007 at 12:30:38PM -0400, Bhavana.Rakesh wrote:
>>>>>>> Oliver,
>>>>>>>
>>>>>>> When I do a :
>>>>>>> psql -p 5000 testing123
>>>>>>> I can make a connection. However, when I do a
>>>>>>>
>>>>>>> psql -U brakesh -h 127.0.0.1 -d testing123
>>>>>>>
>>>>>>> I get the followign error:
>>>>>>>
>>>>>>> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user
>>>>>>> "brakesh",
>>>>>>> database "testing123", SSL off
>>>>>>
>>>>>> Ofcourse, the first connection is a local connection, which you
>>>>>> obviously have configured. The latter connects to localhost, which you
>>>>>> havn't configured.
>>>>>
>>>>> His original message (which I snipped) said he had:
>>>>>
>>>>> # IPv4-style local connections:
>>>>> host all all 127.0.0.1 255.255.255.255
>>>>> trust
>>>>> host testing123 brakesh 127.0.0.1 255.255.255.255
>>>>> trust
>>>>>
>>>>> So it seems to me he did have it configured.
>>>>>
>>>>> In fact the first host line should be used and the second one for user
>>>>> brakesh is redundant, since it comes later in the file. The only thing
>>>>> I can see is that it might be related to SSL.
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>

--
Louis Gonzales
louis(dot)gonzales(at)linuxlouis(dot)net
http://www.linuxlouis.net


From: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 12:57:41
Message-ID: 465EC645.3010905@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Ok,
I confirmed that I'm editing the right pg_hba.conf file. I made sure
that there are no other postmasters running. I made sure that there is
a user called 'brakesh'. I restart the postmaster everytime I make any
changes to pg_hba.conf file. But still same results!

[brakesh(at)lnx383 ~/db_connect]$ psql -U brakesh -h 127.0.0.1 -d testing123
psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
database "testing123", SSL off

[brakesh(at)lnx383 ~/db_connect]$ psql -p 5000 testing123
Welcome to psql 7.4.17, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
______________________________________
Here is my pg_hba.conf file again. I've commented the different records
that I've experimented with. But none of them worked. Of course, when
i commented out the first record
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
local all all trust

I couldn't connect using the 'psql -p 5000 testing123'..which confirmed
that I'm editing the right pg_hba.conf file. My current working copy of
pg_hba.conf file follows:

____________________________________________

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
local all all trust

# IPv4-style local connections:
#host all all 127.0.0.1 255.255.255.255 trust
#host testing123 brakesh 127.0.0.1 255.255.255.255 trust
hostnossl testing123 brakesh 127.0.0.1 255.255.255.255 trust
#hostnossl all all 127.0.0.1 255.255.255.255 trust
#hostnossl testing123 brakesh 127.0.0.1
255.255.255.255 trust
# IPv6-style local connections:
#host all all ::1/128
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff trust

#Allow any user from any host with IP address 140.90.193.238 to
# connect to database "testing123" as the same username that ident on that
# host identifies him as (typically his Unix username):
#
#TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
#hostnossl testing123 all 140.90.193.238 255.255.255.0 ident
sameuser

Tom Lane wrote:
> Oliver Elphick <olly(at)lfix(dot)co(dot)uk> writes:
>
>> His original message (which I snipped) said he had:
>>
>
>
>> # IPv4-style local connections:
>> host all all 127.0.0.1 255.255.255.255 trust
>> host testing123 brakesh 127.0.0.1 255.255.255.255 trust
>>
>
>
>> So it seems to me he did have it configured.
>>
>
> I've seen similar problems resolved by discovering that (1) the DBA
> was editing the wrong copy of the pg_hba.conf file, or (2) there was
> actually more than one postmaster running on the machine.
>
> Check "ps" for multiple postmasters. Put a deliberate error in the
> pg_hba.conf file and verify that the postmaster fails to restart.
>
> regards, tom lane
>


From: "chris smith" <dmagick(at)gmail(dot)com>
To: Bhavana(dot)Rakesh <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 13:24:59
Message-ID: 3c1395330705310624q793f8f82n8b8ba240e1acf195@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 5/31/07, Bhavana.Rakesh <Bhavana(dot)Rakesh(at)noaa(dot)gov> wrote:
>
> Ok,
> I confirmed that I'm editing the right pg_hba.conf file. I made sure that
> there are no other postmasters running. I made sure that there is a user
> called 'brakesh'. I restart the postmaster everytime I make any changes to
> pg_hba.conf file. But still same results!
>
> [brakesh(at)lnx383 ~/db_connect]$ psql -U brakesh -h 127.0.0.1 -d testing123
> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
> database "testing123", SSL off
>
>
> [brakesh(at)lnx383 ~/db_connect]$ psql -p 5000 testing123
> Welcome to psql 7.4.17, the PostgreSQL interactive terminal.

Why are you specifying the port number when you don't include the host?

What happens if you do include the port:

psql -U brakesh -p 5000 -h 127.0.0.1 -d testing123

--
Postgresql & php tutorials
http://www.designmagick.com/


From: Ray Stell <stellr(at)cns(dot)vt(dot)edu>
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Oliver Elphick <olly(at)lfix(dot)co(dot)uk>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 13:27:00
Message-ID: 20070531132700.GB12941@cns.vt.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


What is listen_addresses set to in postgresql.conf?
'*' corresponds to all available IP interfaces. Maybe
you are not listening on localhost.

On Thu, May 31, 2007 at 08:57:41AM -0400, Bhavana.Rakesh wrote:
> Ok,
> I confirmed that I'm editing the right pg_hba.conf file. I made sure
> that there are no other postmasters running. I made sure that there is
> a user called 'brakesh'. I restart the postmaster everytime I make any
> changes to pg_hba.conf file. But still same results!
>
> [brakesh(at)lnx383 ~/db_connect]$ psql -U brakesh -h 127.0.0.1 -d testing123
> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "brakesh",
> database "testing123", SSL off
>
>
> [brakesh(at)lnx383 ~/db_connect]$ psql -p 5000 testing123
> Welcome to psql 7.4.17, the PostgreSQL interactive terminal.
>
> Type: \copyright for distribution terms
> \h for help with SQL commands
> \? for help on internal slash commands
> \g or terminate with semicolon to execute query
> \q to quit
> ______________________________________
> Here is my pg_hba.conf file again. I've commented the different records
> that I've experimented with. But none of them worked. Of course, when
> i commented out the first record
> # TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
> local all all trust
>
> I couldn't connect using the 'psql -p 5000 testing123'..which confirmed
> that I'm editing the right pg_hba.conf file. My current working copy of
> pg_hba.conf file follows:
>
> ____________________________________________
>
> # TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
> local all all trust
>
> # IPv4-style local connections:
> #host all all 127.0.0.1 255.255.255.255 trust
> #host testing123 brakesh 127.0.0.1 255.255.255.255 trust
> hostnossl testing123 brakesh 127.0.0.1 255.255.255.255 trust
> #hostnossl all all 127.0.0.1 255.255.255.255 trust
> #hostnossl testing123 brakesh 127.0.0.1
> 255.255.255.255 trust
> # IPv6-style local connections:
> #host all all ::1/128
> ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff trust
>
>
> #Allow any user from any host with IP address 140.90.193.238 to
> # connect to database "testing123" as the same username that ident on that
> # host identifies him as (typically his Unix username):
> #
> #TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
> #hostnossl testing123 all 140.90.193.238 255.255.255.0 ident
> sameuser
>
>
> Tom Lane wrote:
> >Oliver Elphick <olly(at)lfix(dot)co(dot)uk> writes:
> >
> >>His original message (which I snipped) said he had:
> >>
> >
> >
> >># IPv4-style local connections:
> >>host all all 127.0.0.1 255.255.255.255 trust
> >>host testing123 brakesh 127.0.0.1 255.255.255.255 trust
> >>
> >
> >
> >>So it seems to me he did have it configured.
> >>
> >
> >I've seen similar problems resolved by discovering that (1) the DBA
> >was editing the wrong copy of the pg_hba.conf file, or (2) there was
> >actually more than one postmaster running on the machine.
> >
> >Check "ps" for multiple postmasters. Put a deliberate error in the
> >pg_hba.conf file and verify that the postmaster fails to restart.
> >
> > regards, tom lane
> >

--
Lost time is when we learn nothing from the experiences of life. Time
gained is when we grow to have a wisdom that is tested in the reality of life.


From: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
To: chris smith <dmagick(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 13:38:51
Message-ID: 465ECFEB.3020009@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,
Here's what happens when I specify the port number

[brakesh(at)lnx383 ~]$ psql -U brakesh -p 5000 -h 127.0.0.1 -d testing123
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5000?

I have the listen_address in

postgresql.conf

file set as follows:

#---------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#---------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
# (change requires restart)
#port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)

-Bhavana

chris smith wrote:
> On 5/31/07, Bhavana.Rakesh <Bhavana(dot)Rakesh(at)noaa(dot)gov> wrote:
>>
>> Ok,
>> I confirmed that I'm editing the right pg_hba.conf file. I made
>> sure that
>> there are no other postmasters running. I made sure that there is a
>> user
>> called 'brakesh'. I restart the postmaster everytime I make any
>> changes to
>> pg_hba.conf file. But still same results!
>>
>> [brakesh(at)lnx383 ~/db_connect]$ psql -U brakesh -h 127.0.0.1 -d
>> testing123
>> psql: FATAL: no pg_hba.conf entry for host "127.0.0.1", user
>> "brakesh",
>> database "testing123", SSL off
>>
>>
>> [brakesh(at)lnx383 ~/db_connect]$ psql -p 5000 testing123
>> Welcome to psql 7.4.17, the PostgreSQL interactive terminal.
>
> Why are you specifying the port number when you don't include the host?
>
> What happens if you do include the port:
>
> psql -U brakesh -p 5000 -h 127.0.0.1 -d testing123
>


From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 13:50:50
Message-ID: 1180619450.15764.166.camel@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, 2007-05-31 at 09:38 -0400, Bhavana.Rakesh wrote:
> Hi,
> Here's what happens when I specify the port number
>
> [brakesh(at)lnx383 ~]$ psql -U brakesh -p 5000 -h 127.0.0.1 -d testing123
> psql: could not connect to server: Connection refused
> Is the server running on host "127.0.0.1" and accepting
> TCP/IP connections on port 5000?

Since that command without "-h 127.0.0.1" does work, the clear
implication is that somehow there is a postmaster listening on port 5000
to Unix sockets and a different postmaster, presumably with a different
pg_hba.conf, listening on port 5432 on 127.0.0.1.

--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
Do you want to know God? http://www.lfix.co.uk/knowing_god.html


From: Ray Stell <stellr(at)cns(dot)vt(dot)edu>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 14:12:31
Message-ID: 20070531141231.GC12941@cns.vt.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


What does netstat -l tell us about that?

On Thu, May 31, 2007 at 02:50:50PM +0100, Oliver Elphick wrote:
> On Thu, 2007-05-31 at 09:38 -0400, Bhavana.Rakesh wrote:
> > Hi,
> > Here's what happens when I specify the port number
> >
> > [brakesh(at)lnx383 ~]$ psql -U brakesh -p 5000 -h 127.0.0.1 -d testing123
> > psql: could not connect to server: Connection refused
> > Is the server running on host "127.0.0.1" and accepting
> > TCP/IP connections on port 5000?
>
> Since that command without "-h 127.0.0.1" does work, the clear
> implication is that somehow there is a postmaster listening on port 5000
> to Unix sockets and a different postmaster, presumably with a different
> pg_hba.conf, listening on port 5432 on 127.0.0.1.
>
>
> --
> Oliver Elphick olly(at)lfix(dot)co(dot)uk
> Isle of Wight http://www.lfix.co.uk/oliver
> GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
> ========================================
> Do you want to know God? http://www.lfix.co.uk/knowing_god.html
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org/

--
Lost time is when we learn nothing from the experiences of life. Time
gained is when we grow to have a wisdom that is tested in the reality of life.


From: gonzales(at)linuxlouis(dot)net
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 14:26:20
Message-ID: Pine.LNX.4.64.0705311019020.32407@mx1.linuxlouis.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

W/out specifying a -h switch, postgres defaults to using a UNIX domain
socket, meaning AF_UNIX and not AF_INET. There is a big difference.
Using -h 127.0.0.1 is the localhost not necessarily 'local' from the
context of postgres. W/out looking into the details, I think 'local' is
referring to AF_UNIX. In other words, without specyfing the -h switch,
when you have connected, do a "netstat -an" you'll see there are no
TCP/IP(AF_INET) sockets connected, but rather there is a AF_UNIX socket
connected which will be somewhere in /tmp/blah.s.psostgres.5000 or
something similar.

On Thu, 31 May 2007, Oliver Elphick wrote:

> On Thu, 2007-05-31 at 09:38 -0400, Bhavana.Rakesh wrote:
>> Hi,
>> Here's what happens when I specify the port number
>>
>> [brakesh(at)lnx383 ~]$ psql -U brakesh -p 5000 -h 127.0.0.1 -d testing123
>> psql: could not connect to server: Connection refused
>> Is the server running on host "127.0.0.1" and accepting
>> TCP/IP connections on port 5000?
>
> Since that command without "-h 127.0.0.1" does work, the clear
> implication is that somehow there is a postmaster listening on port 5000
> to Unix sockets and a different postmaster, presumably with a different
> pg_hba.conf, listening on port 5432 on 127.0.0.1.
>
>
>

--
Louis Gonzales
louis(dot)gonzales(at)linuxlouis(dot)net
http://www.linuxlouis.net


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: chris smith <dmagick(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 17:17:56
Message-ID: 20070531171756.GA18911@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Bhavana.Rakesh escribió:
> Hi,
> Here's what happens when I specify the port number
>
> [brakesh(at)lnx383 ~]$ psql -U brakesh -p 5000 -h 127.0.0.1 -d testing123
> psql: could not connect to server: Connection refused
> Is the server running on host "127.0.0.1" and accepting
> TCP/IP connections on port 5000?

This one is not listening on port 5000 -- it's the default 5432, unless
you have the port set elsewhere on the .conf file.

> #---------------------------------------------------------------------------
> # CONNECTIONS AND AUTHENTICATION
> #---------------------------------------------------------------------------
>
> # - Connection Settings -
>
> listen_addresses = '*' # what IP address(es) to listen on;
> # comma-separated list of addresses;
> # defaults to 'localhost', '*' = all
> # (change requires restart)
> #port = 5432 # (change requires restart)
> max_connections = 100 # (change requires restart)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
Cc: chris smith <dmagick(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 20:07:25
Message-ID: 11708.1180642045@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

"Bhavana.Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov> writes:
> Here's what happens when I specify the port number

> [brakesh(at)lnx383 ~]$ psql -U brakesh -p 5000 -h 127.0.0.1 -d testing123
> psql: could not connect to server: Connection refused
> Is the server running on host "127.0.0.1" and accepting
> TCP/IP connections on port 5000?

5000 being a nonstandard port number, it's certainly possible that the
kernel is filtering this connection attempt. "Connection refused" might
mean either that there's no process listening to TCP port 5000, or that
the kernel rejected the connection before looking for a listening process.

In any case it seems highly probable that you do have two postmasters
running on this machine, one at port 5000 and one at port 5432. The
psql calls without an explicit -p switch would have defaulted to port
5432 unless you've done something strange to your installation.

regards, tom lane


From: Ray Stell <stellr(at)cns(dot)vt(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>, chris smith <dmagick(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-05-31 21:33:03
Message-ID: 20070531213303.GH12941@cns.vt.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, May 31, 2007 at 04:07:25PM -0400, Tom Lane wrote:
> the kernel rejected the connection before looking for a listening process.

or a host-based firewall might produce the same result.


From: "Bhavana(dot)Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: chris smith <dmagick(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: jdbc pg_hba.conf error
Date: 2007-06-05 13:35:46
Message-ID: 466566B2.2000705@noaa.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Starting the postmaster with a "-i" option did the trick.

/ -i Allows clients to connect via TCP/IP (Internet domain)
connections. Without this
option, only local Unix domain socket connections are
accepted. This option corre-
sponds to setting tcpip_socket=true in postgresql.conf.

--tcpip-socket=false has the opposite effect of this option.

/However, this still does not solve my problem of having a java
application connect to the postgres DB server. I get the following error:

Couldn't connect: print out a stack trace and exit.
org.postgresql.util.PSQLException: A connection error has occurred:
org.postgres ql.util.PSQLException: FATAL: no
pg_hba.conf entry for host "127.0.0.1", user "b
rakesh", database "testing123", SSL off

at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV3(Abstrac
tJdbc1Connection.java:337)
at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJ
dbc1Connection.java:214)
at org.postgresql.Driver.connect(Driver.java:139)
at java.sql.DriverManager.getConnection(DriverManager.java:559)
at java.sql.DriverManager.getConnection(DriverManager.java:189)
at db_connect_pgsql.main(db_connect_pgsql.java:25)

-Bhavana
Tom Lane wrote:
> "Bhavana.Rakesh" <Bhavana(dot)Rakesh(at)noaa(dot)gov> writes:
>
>> Here's what happens when I specify the port number
>>
>
>
>> [brakesh(at)lnx383 ~]$ psql -U brakesh -p 5000 -h 127.0.0.1 -d testing123
>> psql: could not connect to server: Connection refused
>> Is the server running on host "127.0.0.1" and accepting
>> TCP/IP connections on port 5000?
>>
>
> 5000 being a nonstandard port number, it's certainly possible that the
> kernel is filtering this connection attempt. "Connection refused" might
> mean either that there's no process listening to TCP port 5000, or that
> the kernel rejected the connection before looking for a listening process.
>
> In any case it seems highly probable that you do have two postmasters
> running on this machine, one at port 5000 and one at port 5432. The
> psql calls without an explicit -p switch would have defaulted to port
> 5432 unless you've done something strange to your installation.
>
> regards, tom lane
>