Thread: problem with Connection refused

problem with Connection refused

From
rdkurth@starband.net
Date:
Hello pgsql-novice,

I keep getting this when I try to access the PostgreSQL database. The
funny thing is this used to work. I am using a cobalt Linux server.
And Postgresql is used for the GUI on that server . The GUI works I
just can't access this other Database.
How can I start the server with the -i . PostgreSQL is started at boot
up with the script down below how can I change that to use the -i
switch or do I even halve to

PHP Warning:  pg_pconnect() unable to connect to PostgreSQL server: PQconnec
tPoll() -- connect() failed: Connection refused
        Is the postmaster running (with -i) at '127.0.0.1'
        and accepting connections on TCP/IP port '5901'?

############THIS IS MY pg_hba.conf FILE#######################
local cobalt crypt
local eprop crypt
host eprop 127.0.0.1 255.255.255.255 crypt


#########THIS IS THE START UP SCRIPT#################
#!/bin/bash

# postgresql    This is the init script for starting up the PostgreSQL
#               server
#
# chkconfig:   345 73 73
# description: Starts and stops the PostgreSQL backend daemon
# processname: postmaster
# pidfile:     /var/run/postmaster.pid
#

[ -x /usr/bin/postmaster        ] || exit 1
[ -s /etc/rc.d/init.d/functions ] || exit 1
[ -s /etc/sysconfig/network     ] || exit 1

. /etc/rc.d/init.d/functions
. /etc/sysconfig/network

[ $NETWORKING = "no"     ] && exit 0
[ -s /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n

VERBOSE=yes
[ "$2" = "quiet" ] && VERBOSE=

DOMAIN=initscripts
PIDFILE=/var/run/postmaster.pid
LOCKFILE=/var/lock/subsys/postgresql
PGDATA=/var/lib/pgsql/data
export PGDATA

case "$1" in
    start)
        if [ $VERBOSE ]; then
            LINE1=`getmsg postgresql_start_1`
            LINE2=`getmsg postgresql_start_2`
            $LCD_STOP
            $LCD_SWRITE "$LINE1" "$LINE2" &> /dev/null &
            echo -n "$LINE1 $LINE2: "
        fi

        if [ -s $PGDATA/PG_VERSION -a -d $PGDATA/base/template1 ]; then
            if [ `cat $PGDATA/PG_VERSION` != "7.0" ]; then
                [ $VERBOSE ] && echo "old version, upgrade to 7.0!"
                exit 1
            fi
        else
            [ $VERBOSE ] && echo "no database files found.  creating..."
            if [ ! -d $PGDATA ]; then
                mkdir -p $PGDATA
                chown postgres.postgres $PGDATA
            fi
            su postgres -c "/usr/bin/initdb --pglib=/usr/lib/pgsql --pgdata=$PGDATA"
        fi

        pid=`pidof postmaster`
        if [ $pid ]; then
            [ $VERBOSE ] && echo "postmaster already running!"
            exit 1
        fi

        rm -f /tmp/.s.PGSQL.*
        su postgres -c  "nohup /usr/bin/postmaster  >> /var/log/postgresql 2>&1 &"
        sleep 1

        pid=`pidof postmaster`
        if [ $pid ]; then
            [ $VERBOSE ] && echo "ok [$pid]"
            echo $pid > $PIDFILE
            touch $LOCKFILE
        else
            [ $VERBOSE     ] && echo "failed!"
            [ -f $PIDFILE  ] && rm -f $PIDFILE
            [ -f $LOCKFILE ] && rm -f $LOCKFILE
            exit 1
        fi

        if [ ! -d $PGDATA/base/cobalt ]; then
            /usr/local/sbin/setup-postgres
        fi
        ;;

    stop)
        if [ $VERBOSE ]; then
            LINE1=`getmsg postgresql_stop_1`
            LINE2=`getmsg postgresql_stop_2`
            $LCD_STOP
            $LCD_SWRITE "$LINE1" "$LINE2" &> /dev/null &
            echo -n "$LINE1 $LINE2: "
        fi

        pid=`pidof postmaster`
        if [ $pid ]; then
            if [ -s $PIDFILE ] && [ `cat $PIDFILE` != $pid ]; then
                [ $VERBOSE ] && echo -n "process ID mismatch! "
            fi
            kill $pid
            sleep 2
            killall /usr/bin/postgres >/dev/null 2>&1

            [ $VERBOSE ] && echo "ok"
        else
            [ $VERBOSE ] && echo "not running!"
        fi

        [ -f $PIDFILE  ] && rm -f $PIDFILE
        [ -f $LOCKFILE ] && rm -f $LOCKFILE
        ;;

    status)
        status postmaster
        ;;

    restart)
        EXTRA=
        [ $VERBOSE ] || EXTRA=quiet
        $0 stop $EXTRA
        $0 start $EXTRA
        ;;

    hard-restart)
        $0 stop quiet
        $0 start quiet
        ;;

    *)
        echo "Usage: postgresql {start|stop|status|restart} [quiet]"
        exit 1

esac

exit 0





--
Best regards,
 rdkurth                          mailto:rdkurth@starband.net


Re: problem with Connection refused

From
Oliver Elphick
Date:
On Wed, 2002-08-21 at 05:02, rdkurth@starband.net wrote:
> Hello pgsql-novice,
>
> I keep getting this when I try to access the PostgreSQL database. The
> funny thing is this used to work. I am using a cobalt Linux server.
> And Postgresql is used for the GUI on that server . The GUI works I
> just can't access this other Database.
> How can I start the server with the -i . PostgreSQL is started at boot
> up with the script down below how can I change that to use the -i
> switch or do I even halve to
>
> PHP Warning:  pg_pconnect() unable to connect to PostgreSQL server: PQconnec
> tPoll() -- connect() failed: Connection refused
>         Is the postmaster running (with -i) at '127.0.0.1'
>         and accepting connections on TCP/IP port '5901'?

It's trying to connect to a non-standard port (5901) and I didn't see
anything in your start-up script to indicate that postmaster would be
listening on that port.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK
http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "For the Lord himself shall descend from heaven with a
      shout, with the voice of the archangel, and with the
      trump of God; and the dead in Christ shall rise first;
      Then we which are alive and remain shall be caught
      up together with them in the clouds, to meet the Lord
      in the air; and so shall we ever be with the Lord."
                          I Thessalonians 4:16,17