Thread: Failing tcp/ip connection

Failing tcp/ip connection

From
thiemo
Date:
Hi,


I try to set up a jdbc connection but I fail. I think I have set it up
correctly however with dbvisualizer I get the following error when I
try to connect.



################################################################

Etwas ungewöhnliches ist passiert.  Bitte Teilen Sie diesem Fehler
mit: Exception: java.sql.SQLException: FATAL 1:  No pg_hba.conf entry
for host 192.168.0.249, user postgres, database template1


Stack Trace:


java.sql.SQLException: FATAL 1:  No pg_hba.conf entry for host
192.168.0.249, user postgres, database template1


    at org.postgresql.Connection.openConnection(Connection.java:178)

    at org.postgresql.Driver.connect(Driver.java:149)

    at java.sql.DriverManager.getConnection(DriverManager.java:517)

    at java.sql.DriverManager.getConnection(DriverManager.java:177)

    at
se.pureit.dbvis.wrapper.DriverManagerImpl.getConnection(DriverManagerImpl.java:31)

    at se.pureit.dbvis.Database.doConnect(Database.java:180)

    at se.pureit.dbvis.Database.access$0(Database.java:170)

    at
se.pureit.dbvis.Database$ConnectionCommand.execute(Database.java:1022)

    at se.pureit.util.ThreadCommand.runExecute(ThreadCommand.java:161)

    at se.pureit.util.ThreadCommand.run(ThreadCommand.java:141)

    at java.lang.Thread.run(Thread.java:496)

End of Stack Trace


Etwas ungewöhnliches ist passiert.  Bitte Teilen Sie diesem Fehler
mit: Exception: java.sql.SQLException: FATAL 1:  No pg_hba.conf entry
for host 192.168.0.249, user postgres, database template1


Stack Trace:


java.sql.SQLException: FATAL 1:  No pg_hba.conf entry for host
192.168.0.249, user postgres, database template1


    at org.postgresql.Connection.openConnection(Connection.java:178)

    at org.postgresql.Driver.connect(Driver.java:149)

    at java.sql.DriverManager.getConnection(DriverManager.java:517)

    at java.sql.DriverManager.getConnection(DriverManager.java:177)

    at
se.pureit.dbvis.wrapper.DriverManagerImpl.getConnection(DriverManagerImpl.java:31)

    at se.pureit.dbvis.Database.doConnect(Database.java:180)

    at se.pureit.dbvis.Database.access$0(Database.java:170)

    at
se.pureit.dbvis.Database$ConnectionCommand.execute(Database.java:1022)

    at se.pureit.util.ThreadCommand.runExecute(ThreadCommand.java:161)

    at se.pureit.util.ThreadCommand.run(ThreadCommand.java:141)

    at java.lang.Thread.run(Thread.java:496)

End of Stack Trace

##############################################################


My pg_hba.conf looks like this (at least the lines that aren't
commented out). This file is located where my database directory is
(/var/lib/pgsql). The third line is not necessairy as I understand. I
put it to figure out if line 4 was bad.<fontfamily><param>Helvetica</param>

</fontfamily>################################################################

local      all                                          crypt

host       all         127.0.0.1     255.255.255.255    crypt

host       all         192.168.0.249   255.255.255.255      crypt

host       all         192.168.0.0   255.255.255.0      crypt

################################################################


I feel a bit stupid as I already had a running 7.2 on this machine,
but I didn't want to run into sequence trouble anyhow. As I had about
nothing on the 7.2 I just erased the databse directory.


I'd appreciate any help.


Thx


Thiemo


<fontfamily><param>Helvetica</param>--

Thiemo Kellner

Tösstalstrasse 146

CH-8400 Winterthur

</fontfamily>Hi,

I try to set up a jdbc connection but I fail. I think I have set it up
correctly however with dbvisualizer I get the following error when I try
to connect.

################################################################
Etwas ungewöhnliches ist passiert.  Bitte Teilen Sie diesem Fehler mit:
Exception: java.sql.SQLException: FATAL 1:  No pg_hba.conf entry for
host 192.168.0.249, user postgres, database template1

Stack Trace:

java.sql.SQLException: FATAL 1:  No pg_hba.conf entry for host
192.168.0.249, user postgres, database template1

    at org.postgresql.Connection.openConnection(Connection.java:178)
    at org.postgresql.Driver.connect(Driver.java:149)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at
se.pureit.dbvis.wrapper.DriverManagerImpl.getConnection
(DriverManagerImpl.java:31)
    at se.pureit.dbvis.Database.doConnect(Database.java:180)
    at se.pureit.dbvis.Database.access$0(Database.java:170)
    at
se.pureit.dbvis.Database$ConnectionCommand.execute(Database.java:1022)
    at se.pureit.util.ThreadCommand.runExecute(ThreadCommand.java:161)
    at se.pureit.util.ThreadCommand.run(ThreadCommand.java:141)
    at java.lang.Thread.run(Thread.java:496)
End of Stack Trace

Etwas ungewöhnliches ist passiert.  Bitte Teilen Sie diesem Fehler mit:
Exception: java.sql.SQLException: FATAL 1:  No pg_hba.conf entry for
host 192.168.0.249, user postgres, database template1

Stack Trace:

java.sql.SQLException: FATAL 1:  No pg_hba.conf entry for host
192.168.0.249, user postgres, database template1

    at org.postgresql.Connection.openConnection(Connection.java:178)
    at org.postgresql.Driver.connect(Driver.java:149)
    at java.sql.DriverManager.getConnection(DriverManager.java:517)
    at java.sql.DriverManager.getConnection(DriverManager.java:177)
    at
se.pureit.dbvis.wrapper.DriverManagerImpl.getConnection
(DriverManagerImpl.java:31)
    at se.pureit.dbvis.Database.doConnect(Database.java:180)
    at se.pureit.dbvis.Database.access$0(Database.java:170)
    at
se.pureit.dbvis.Database$ConnectionCommand.execute(Database.java:1022)
    at se.pureit.util.ThreadCommand.runExecute(ThreadCommand.java:161)
    at se.pureit.util.ThreadCommand.run(ThreadCommand.java:141)
    at java.lang.Thread.run(Thread.java:496)
End of Stack Trace
##############################################################

My pg_hba.conf looks like this (at least the lines that aren't commented
out). This file is located where my database directory is
(/var/lib/pgsql). The third line is not necessairy as I understand. I
put it to figure out if line 4 was bad.
################################################################
local      all                                          crypt
host       all         127.0.0.1     255.255.255.255    crypt
host       all         192.168.0.249   255.255.255.255      crypt
host       all         192.168.0.0   255.255.255.0      crypt
################################################################

I feel a bit stupid as I already had a running 7.2 on this machine, but
I didn't want to run into sequence trouble anyhow. As I had about
nothing on the 7.2 I just erased the databse directory.

I'd appreciate any help.

Thx

Thiemo

--
Thiemo Kellner
Tösstalstrasse 146
CH-8400 Winterthur

Re: Failing tcp/ip connection

From
"Josh Berkus"
Date:
Thiemo,

> ################################################################
> Etwas ungewöhnliches ist passiert.  Bitte Teilen Sie diesem Fehler
> mit: Exception: java.sql.SQLException: FATAL 1:  No pg_hba.conf entry
> for host 192.168.0.249, user postgres, database template1

>
> My pg_hba.conf looks like this (at least the lines that aren't
> commented out). This file is located where my database directory is
> (/var/lib/pgsql). The third line is not necessairy as I understand. I
> put it to figure out if line 4 was bad.
> ################################################################
> local      all                                          crypt
> host       all         127.0.0.1     255.255.255.255    crypt
> host       all         192.168.0.249   255.255.255.255      crypt
> host       all         192.168.0.0   255.255.255.0      crypt
> ################################################################
>
> I feel a bit stupid as I already had a running 7.2 on this machine,
> but I didn't want to run into sequence trouble anyhow. As I had about
> nothing on the 7.2 I just erased the databse directory.

1. Make sure that you are, in fact, accessing the pgsql/data/ directory
that you think you are.
2. Make sure that your startup script isn't accessing an alternate
pg_hba.conf directory.
3. Have you restarted Postmaster since you made the changes to
pg_hba.conf?  Sometimes that's required.

-Josh Berkus



Re: Failing tcp/ip connection

From
thiemo
Date:
<excerpt><excerpt>My pg_hba.conf looks like this (at least the lines
that aren't

(/var/lib/pgsql). The third line is not necessairy as I understand. I

################################################################

local      all                                          crypt

host       all         127.0.0.1     255.255.255.255    crypt

host       all         192.168.0.249   255.255.255.255      crypt

host       all         192.168.0.0   255.255.255.0      crypt

################################################################

</excerpt>

1. Make sure that you are, in fact, accessing the pgsql/data/ directory

that you think you are.

</excerpt>

That's the point I am most unsure about. I don't actually know where
to place the file. My book about postgresql only states to put in the
data directory...


nyffeltrach:/var/lib/pgsql # l

total 56

drwx------    6 postgres postgres     4096 Apr 11 23:09 ./

drwxr-xr-x   31 root     root         4096 Apr 12 03:00 ../

-rw-------    1 postgres daemon        185 Apr 10 23:53 .bash_history

-rw-------    1 postgres daemon          4 Apr  6 12:23 PG_VERSION

drwx------    4 postgres daemon       4096 Apr  6 12:23 base/

drwx------    2 postgres daemon       4096 Apr 11 23:09 global/

drwx------    2 postgres daemon       4096 Apr  6 12:23 pg_clog/

lrwxrwxrwx    1 root     root           27 Apr 11 23:08 pg_hba.conf ->
/root/pg_config/pg_hba.conf

-rw-------    1 postgres daemon       1250 Apr  6 12:23 pg_ident.conf

drwx------    2 postgres daemon       4096 Apr  6 12:23 pg_xlog/

-rw-------    1 postgres postgres     3844 Mar 13 22:08 postgresql.conf

-rw-------    1 postgres daemon         48 Apr 11 23:09 postmaster.opts

-rw-------    1 postgres daemon         41 Apr 11 23:09 postmaster.pid

-r--r--r--    1 root     root         1204 Apr 11 07:47 server.crt

-r--r--r--    1 root     root          887 Apr 11 07:47 server.key


BTW: I also put it physically in this directory as well as into the
bin directory of postgres


<excerpt>2. Make sure that your startup script isn't accessing an
alternate

pg_hba.conf directory.

</excerpt>

Below part of the output of ps ax

12833 ?        S      0:00 su - postgres -c /opt/pgsql/bin/postmaster
-D /var/lib/pgsql

12834 ?        S      0:00 -su -c /opt/pgsql/bin/postmaster
-D /var/lib/pgsql

12843 ?        S      0:00 /opt/pgsql/bin/postmaster -D /var/lib/pgsql


The script is

su - postgres \

    -c "/opt/pgsql/bin/postmaster \

                       -D /var/lib/pgsql \

                       1>> /var/log/postgres/postgreSQL.err \

                       2>> /var/log/postgres/postgreSQL.log" &


<excerpt>3. Have you restarted Postmaster since you made the changes to

pg_hba.conf?  Sometimes that's required.

</excerpt>

Yepp.


Hell, it was a permission problem. Links don't work and when I copied
the file to the data directory I did it as root (I was trying to have
the configs at a central point such that I would not loose it too
easily) and forgot to change the owner...


Thx


Thiemo

<fontfamily><param>Helvetica</param>

--

Thiemo Kellner

Tösstalstrasse 146

CH-8400 Winterthur

</fontfamily>>> My pg_hba.conf looks like this (at least the lines that aren't
>> (/var/lib/pgsql). The third line is not necessairy as I understand. I
>> ################################################################
>> local      all                                          crypt
>> host       all         127.0.0.1     255.255.255.255    crypt
>> host       all         192.168.0.249   255.255.255.255      crypt
>> host       all         192.168.0.0   255.255.255.0      crypt
>> ################################################################
>
> 1. Make sure that you are, in fact, accessing the pgsql/data/ directory
> that you think you are.

That's the point I am most unsure about. I don't actually know where to
place the file. My book about postgresql only states to put in the data
directory...

nyffeltrach:/var/lib/pgsql # l
total 56
drwx------    6 postgres postgres     4096 Apr 11 23:09 ./
drwxr-xr-x   31 root     root         4096 Apr 12 03:00 ../
-rw-------    1 postgres daemon        185 Apr 10 23:53 .bash_history
-rw-------    1 postgres daemon          4 Apr  6 12:23 PG_VERSION
drwx------    4 postgres daemon       4096 Apr  6 12:23 base/
drwx------    2 postgres daemon       4096 Apr 11 23:09 global/
drwx------    2 postgres daemon       4096 Apr  6 12:23 pg_clog/
lrwxrwxrwx    1 root     root           27 Apr 11 23:08 pg_hba.conf ->
/root/pg_config/pg_hba.conf
-rw-------    1 postgres daemon       1250 Apr  6 12:23 pg_ident.conf
drwx------    2 postgres daemon       4096 Apr  6 12:23 pg_xlog/
-rw-------    1 postgres postgres     3844 Mar 13 22:08 postgresql.conf
-rw-------    1 postgres daemon         48 Apr 11 23:09 postmaster.opts
-rw-------    1 postgres daemon         41 Apr 11 23:09 postmaster.pid
-r--r--r--    1 root     root         1204 Apr 11 07:47 server.crt
-r--r--r--    1 root     root          887 Apr 11 07:47 server.key

BTW: I also put it physically in this directory as well as into the bin
directory of postgres

> 2. Make sure that your startup script isn't accessing an alternate
> pg_hba.conf directory.

Below part of the output of ps ax
12833 ?        S      0:00 su - postgres -c
/opt/pgsql/bin/postmaster                        -D /var/lib/pgsql
12834 ?        S      0:00 -su -c
/opt/pgsql/bin/postmaster                        -D /var/lib/pgsql
12843 ?        S      0:00 /opt/pgsql/bin/postmaster -D /var/lib/pgsql

The script is
su - postgres \
     -c "/opt/pgsql/bin/postmaster \
                        -D /var/lib/pgsql \
                        1>> /var/log/postgres/postgreSQL.err \
                        2>> /var/log/postgres/postgreSQL.log" &

> 3. Have you restarted Postmaster since you made the changes to
> pg_hba.conf?  Sometimes that's required.

Yepp.

Hell, it was a permission problem. Links don't work and when I copied
the file to the data directory I did it as root (I was trying to have
the configs at a central point such that I would not loose it too
easily) and forgot to change the owner...

Thx

Thiemo

--
Thiemo Kellner
Tösstalstrasse 146
CH-8400 Winterthur