Bug 56564 - pgaccess cannot connect to database
pgaccess cannot connect to database
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: postgresql (Show other bugs)
7.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: Trond Eivind Glomsrxd
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-11-20 19:53 EST by Daniel Hammer
Modified: 2007-04-18 12:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-11-20 22:22:25 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Daniel Hammer 2001-11-20 19:53:46 EST
$ pgaccess {database} fails with the following error message:

"Connection to database failed
 connectDBStart() -- connect() failed:
 Connection refused"

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. su postgres
2. createdb {database}
3. createuser {user}
4. $ pgaccess {database} (performed as {user})
	

Actual Results:  a popup-window shows the following text:

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


Proposal for a fix:

(a) There is a way to avoid this: just doing $ pgaccess
and deleting manually "localhost" from the popup-window
and manually open the db {database}.

 (b) A much more elegant way to fix the problem would be
to do some little changes in the starting script for the 
daemon: /etc/rc.d/init.d/postgresql.

Change line 62/63 from

 start(){
	PSQL_START=$"Starting postgresql service: "

to

 start(){
	PSQL_START=$"Starting postgresql service: "
	PGOPTS="-i"

and line 135 from 

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

to 

 su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p
   /usr/bin/postmaster -o $PGOPTS start  > /dev/null 2>&1" < /dev/null
Comment 1 David Lawrence 2001-11-20 22:22:19 EST
The preferred way to enable options with PostgreSQL is to edit the config file
located at /var/lib/pgsql/data/postgresql.conf. There you will find a line such as

#tcpip_socket = false

Just uncomment the line and restart PostgreSQL. This will automatically add the
-i and allow pgaccess to work properly.
Comment 2 Daniel Hammer 2001-11-21 05:45:49 EST
Thanx for the prompt answer.
I have tried this before! But, unfortunately, following the steps of 
your suggestion above, this does not work: the postmaster continues 
to start as 
/usr/bin/postmaster -D /var/lib/pgsql/data 
and I continue being denied to get access to the database via pgaccess 
(in the way as I indicated it above).

I've tried this now on several machines with a fresh install and the
following relevant packages installed:

postgresql-7.1.3-2 
postgresql-contrib-7.1.3-2 
postgresql-devel-7.1.3-2 
postgresql-docs-7.1.3-2 
postgresql-jdbc-7.1.3-2 
postgresql-libs-7.1.3-2 
postgresql-odbc-7.1.3-2 
postgresql-perl-7.1.3-2 
postgresql-python-7.1.3-2 
postgresql-server-7.1.3-2 
postgresql-tcl-7.1.3-2 
postgresql-tk-7.1.3-2 
mod_auth_pgsql-0.9.8-1
perl-DBD-Pg-1.01-1 
php-pgsql-4.0.6-7 

and always got the same result.

So this does not work 'n' nothing has changed.
Comment 3 Daniel Hammer 2001-11-21 07:36:43 EST
Ok., sorry for bothering again. 
The (one) right way is to set "tcpip_socket = true"
in
 
/var/lib/pgsql/data/postgresql.conf

to get local access to PostgreSQL. I didn't test 
network access yet, but TCP-port 5432 is open - so
it seems to look good.

But anyway, postmaster seems to start without -i
option:

[root@tunix data]# ps -fu postgres
UID        PID  PPID  C STIME TTY          TIME CMD
postgres  3455     1  0 13:22 pts/2    00:00:00 /usr/bin/postmaster -D  
/var/lib/pgsql/data
postgres  3488  3455  0 13:24 pts/2    00:00:00 postgres: hombre Luach 127.0.0.1
idle     

So, it works. With the changed start script for the daemon as
indicated above the postmaster however starts with "-i" option:

[root@tunix data]#  ps -fu postgres
UID        PID  PPID  C STIME TTY          TIME CMD
postgres  3712     1  0 13:30 pts/2    00:00:00 /usr/bin/postmaster -D
/var/lib/pgsql/data -i
postgres  3724  3712  0 13:30 pts/2    00:00:00 postgres: hombre Luach 127.0.0.1
idle        

In both cases I can locally connect to a database.
But thanx for your help!

Note You need to log in before you can comment on or make changes to this bug.