Обсуждение: Problem with host connection

Поиск
Список
Период
Сортировка

Problem with host connection

От
Jeremy Smith
Дата:
This is a new area to me, I am rewriting a Microsoft Access application for the company
I work for in Java and Postgres.

I have created a testdatabase called history which I can access with <psql history> fine
as well as from a Perl test app I have written.
But if I try to specify a host in either my Java test app or psql I get the same
error message

Connection to database 'history' failed.
connectDB() -- connect() failed: Connection refused
Is the postmaster running (with -i) at '127.0.0.1' and accepting connections on TCP/IP port '5432'?

I also have the same errors when runing under the postgres account.

<psql history> works fine

<psql -p 5432 history) also works fine

<psql -h 127.0.0.1 -p 5432 history> give the following error message
Connection to database 'history' failed.
connectDB() -- connect() failed: Connection refused
Is the postmaster running (with -i) at '127.0.0.1' and accepting connections on TCP/IP port '5432'?

<psql -h 192.168.1.168 -p 5432 history> gives the same error

THE NETWORK SEEMS OK:
PING 127.0.0.1 (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.2 ms

PING 192.168.1.168 (192.168.1.168) from 192.168.1.168 : 56(84) bytes of data.
64 bytes from 192.168.1.168: icmp_seq=0 ttl=255 time=0.2 ms

THE FILE /etc/rc.d/init.d/postgresql contains the following line
       su -l postgres -c '/usr/bin/postmaster -i -S -D /var/lib/pgsql/data'
# originaly the -D variable was /var/lib/pgsql but I changed it to the same as the PGDATA
# setting
# neither seems to make any difference - jeremy

THE FILE /var/lib/pgsql/data/pg_hba.conf contains the following lines at the end:
local        all                                         trust
host         all         127.0.0.1     255.255.255.255   trust

Re: Problem with host connection

От
"John Clark L. Naldoza"
Дата:
Hello Jeremy...

Jeremy Smith wrote:
>
> This is a new area to me, I am rewriting a Microsoft Access
> application for the company

Have you tried using PgAdmin?  It may help you a bit...  Then just iron
out the details afterwards...;-)  It's somewhere in
www.greatbridge.com... I think..;-)

> I work for in Java and Postgres.

JDBC...

>
> I have created a testdatabase called history which I can access with
> <psql history> fine
> as well as from a Perl test app I have written.
> But if I try to specify a host in either my Java test app or psql I
> get the same
> error message
>
> Connection to database 'history' failed.
> connectDB() -- connect() failed: Connection refused
> Is the postmaster running (with -i) at '127.0.0.1' and accepting
> connections on TCP/IP port '5432'?

try a

netstat -a | grep postgres


>
> I also have the same errors when runing under the postgres account.
>
> <psql history> works fine
>
> <psql -p 5432 history) also works fine
>
> <psql -h 127.0.0.1 -p 5432 history> give the following error message
> Connection to database 'history' failed.
> connectDB() -- connect() failed: Connection refused
> Is the postmaster running (with -i) at '127.0.0.1' and accepting
> connections on TCP/IP port '5432'?
>
> <psql -h 192.168.1.168 -p 5432 history> gives the same error
>
> THE NETWORK SEEMS OK:
> PING 127.0.0.1 (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.
> 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.2 ms
>
> PING 192.168.1.168 (192.168.1.168) from 192.168.1.168 : 56(84) bytes
> of data.
> 64 bytes from 192.168.1.168: icmp_seq=0 ttl=255 time=0.2 ms
>
> THE FILE /etc/rc.d/init.d/postgresql contains the following line
>        su -l postgres -c '/usr/bin/postmaster -i -S -D
> /var/lib/pgsql/data'
> # originaly the -D variable was /var/lib/pgsql but I changed it to the
> same as the PGDATA
> # setting
> # neither seems to make any difference - jeremy

This is how it is started in my machine...;-(

su -l postgres -c "/usr/bin/pg_ctl  -D $PGDATA -p /usr/bin/postmaster
start >/dev/null 2>&1"


The -i option is with /var/lib/pgsql/data/postmaster.opts in my
machine...

>
> THE FILE /var/lib/pgsql/data/pg_hba.conf contains the following lines
> at the end:
> local        all                                         trust
> host         all         127.0.0.1     255.255.255.255   trust

As for PGDATA, it's in the script...

    if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d
/var/lib/pgsql/base/template1 ]
    then
        export PGDATA=/var/lib/pgsql
    else
        export PGDATA=/var/lib/pgsql/data
    fi

What version of PostgreSQL are you running?  What O.S. are you running
it in?  And how did you install postgresql?


Cheers,


John Clark

--
     /) John Clark Naldoza y Lopez                           (\
    / )    Software Design Engineer II                       ( \
  _( (_    _  Web-Application Development                    _) )_
 (((\ \>  /_>    Cable Modem Network Management System <_\  </ /)))
 (\\\\ \_/ /         NEC Telecom Software Phils., Inc.  \ \_/ ////)
  \       /                                              \       /
   \    _/  phone: (+63 32) 233-9142 loc. 3112            \_    /
   /   /  cellphone: (+63 919) xxx-xxxx                     \   \
  /   / email: njclark@ntsp.nec.co.jp                        \   \

Re: Problem with host connection

От
Jeremy Smith
Дата:
Hi, Thanks for your response.

netstat did not find postgres ?????????
I do not have a postmaster.opts
I am running version 6.5 on a Mac using Yellowdog Linux 1.2

Jeremy


> From: "John Clark L. Naldoza" <njclark@ntsp.nec.co.jp>
> Organization: NEC Telecom Software
> Date: Mon, 26 Feb 2001 16:57:06 +0800
> To: Jeremy Smith <Jeremy@justasofty.com>
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] Problem with host connection
>
> Hello Jeremy...
>
> Jeremy Smith wrote:
>>
>> This is a new area to me, I am rewriting a Microsoft Access
>> application for the company
>
> Have you tried using PgAdmin?  It may help you a bit...  Then just iron
> out the details afterwards...;-)  It's somewhere in
> www.greatbridge.com... I think..;-)
>
>> I work for in Java and Postgres.
>
> JDBC...
>
>>
>> I have created a testdatabase called history which I can access with
>> <psql history> fine
>> as well as from a Perl test app I have written.
>> But if I try to specify a host in either my Java test app or psql I
>> get the same
>> error message
>>
>> Connection to database 'history' failed.
>> connectDB() -- connect() failed: Connection refused
>> Is the postmaster running (with -i) at '127.0.0.1' and accepting
>> connections on TCP/IP port '5432'?
>
> try a
>
> netstat -a | grep postgres
>
>
>>
>> I also have the same errors when runing under the postgres account.
>>
>> <psql history> works fine
>>
>> <psql -p 5432 history) also works fine
>>
>> <psql -h 127.0.0.1 -p 5432 history> give the following error message
>> Connection to database 'history' failed.
>> connectDB() -- connect() failed: Connection refused
>> Is the postmaster running (with -i) at '127.0.0.1' and accepting
>> connections on TCP/IP port '5432'?
>>
>> <psql -h 192.168.1.168 -p 5432 history> gives the same error
>>
>> THE NETWORK SEEMS OK:
>> PING 127.0.0.1 (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.
>> 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.2 ms
>>
>> PING 192.168.1.168 (192.168.1.168) from 192.168.1.168 : 56(84) bytes
>> of data.
>> 64 bytes from 192.168.1.168: icmp_seq=0 ttl=255 time=0.2 ms
>>
>> THE FILE /etc/rc.d/init.d/postgresql contains the following line
>> su -l postgres -c '/usr/bin/postmaster -i -S -D
>> /var/lib/pgsql/data'
>> # originaly the -D variable was /var/lib/pgsql but I changed it to the
>> same as the PGDATA
>> # setting
>> # neither seems to make any difference - jeremy
>
> This is how it is started in my machine...;-(
>
> su -l postgres -c "/usr/bin/pg_ctl  -D $PGDATA -p /usr/bin/postmaster
> start >/dev/null 2>&1"
>
>
> The -i option is with /var/lib/pgsql/data/postmaster.opts in my
> machine...
>
>>
>> THE FILE /var/lib/pgsql/data/pg_hba.conf contains the following lines
>> at the end:
>> local        all                                         trust
>> host         all         127.0.0.1     255.255.255.255   trust
>
> As for PGDATA, it's in the script...
>
> if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d
> /var/lib/pgsql/base/template1 ]
> then
> export PGDATA=/var/lib/pgsql
> else
> export PGDATA=/var/lib/pgsql/data
> fi
>
> What version of PostgreSQL are you running?  What O.S. are you running
> it in?  And how did you install postgresql?
>
>
> Cheers,
>
>
> John Clark
>
> --
> /) John Clark Naldoza y Lopez                           (¥
> / )    Software Design Engineer II                       ( ¥
> _( (_    _  Web-Application Development                    _) )_
> (((¥ ¥>  /_>    Cable Modem Network Management System <_¥  </ /)))
> (¥¥¥¥ ¥_/ /         NEC Telecom Software Phils., Inc.  ¥ ¥_/ ////)
> ¥       /                                              ¥       /
> ¥    _/  phone: (+63 32) 233-9142 loc. 3112            ¥_    /
> /   /  cellphone: (+63 919) xxx-xxxx                     ¥   ¥
> /   / email: njclark@ntsp.nec.co.jp                        ¥   ¥
>


Re: Problem with host connection

От
"Richard Huxton"
Дата:
From: "Jeremy Smith" <Jeremy@justasofty.com>

> Hi, Thanks for your response.
>
> netstat did not find postgres ?????????

If netstat doesn't list it (nr the top, with a Proto of tcp) then it isn't
listening. The other test is to "telnet localhost 5432" which should show
nothing if pg is listening, connection refused otherwise.

Try "/etc/rc.d/init.d/postgresql restart" and see if that helps and if not
whether there is anything useful in the logs. Failing that, su to postgres
and run the command-line by hand - there should be some sort of error
message.

> I do not have a postmaster.opts
> I am running version 6.5 on a Mac using Yellowdog Linux 1.2

These two things are connected, don't worry about postmaster.opts since that
was introduced in 7.0/1.

You should have no problem compiling 7.x from source when you want to
upgrade - worked just fine on my iBook running LinuxPPC.

>
> Jeremy



Re: Problem with host connection

От
Doug McNaught
Дата:
Jeremy Smith <Jeremy@justasofty.com> writes:

> This is a new area to me, I am rewriting a Microsoft Access
> application for the company I work for in Java and Postgres.  I have
> created a testdatabase called history which I can access with <psql
> history> fine as well as from a Perl test app I have written.  But
> if I try to specify a host in either my Java test app or psql I get
> the same error message

> Connection to database 'history' failed.
> connectDB() -- connect() failed: Connection refused
> Is the postmaster running (with -i) at '127.0.0.1' and accepting connections
> on TCP/IP port '5432'?

By all evidence you're not running the postmaster with '-i'.  Chechk
your startup script.

-Doug

Re: Problem with host connection

От
Jeremy Smith
Дата:
Hi, After listening to others it seems best to run 7.0 and so rather than
carry on I decided to remove all traces of 6.5 and install 7.0 once I have
downloaded it. (have not had chance yet, hope to tonight)

At the same time while removing 6.5 I did notice a running of postmaster at
the end of my inittab which did not have a -i in it so I think that was the
problem?

Jeremy

> From: "Richard Huxton" <dev@archonet.com>
> Date: Mon, 26 Feb 2001 14:02:21 -0000
> To: "Jeremy Smith" <Jeremy@justasofty.com>, "John Clark L. Naldoza"
> <njclark@ntsp.nec.co.jp>
> Cc: <pgsql-general@postgresql.org>
> Subject: Re: [GENERAL] Problem with host connection
>
> From: "Jeremy Smith" <Jeremy@justasofty.com>
>
>> Hi, Thanks for your response.
>>
>> netstat did not find postgres ?????????
>
> If netstat doesn't list it (nr the top, with a Proto of tcp) then it isn't
> listening. The other test is to "telnet localhost 5432" which should show
> nothing if pg is listening, connection refused otherwise.
>
> Try "/etc/rc.d/init.d/postgresql restart" and see if that helps and if not
> whether there is anything useful in the logs. Failing that, su to postgres
> and run the command-line by hand - there should be some sort of error
> message.
>
>> I do not have a postmaster.opts
>> I am running version 6.5 on a Mac using Yellowdog Linux 1.2
>
> These two things are connected, don't worry about postmaster.opts since that
> was introduced in 7.0/1.
>
> You should have no problem compiling 7.x from source when you want to
> upgrade - worked just fine on my iBook running LinuxPPC.
>
>>
>> Jeremy
>
>
>