🙁

Hello,

Any help would be appreciated. I’ve identified the problem marked issue, and I’ve tried the solution, as well as other possible solutions I found by others with the similar issue, and nothing seams to work. I’m trying to connect to port 5432 on the datbase server. Is there anything else I should check or try? Looking for a life saver!!

####

ISSUE

psql: could not connect to server: Connection refused
Is the server running on host server.joe.com and accepting
TCP/IP connections on port 5432?
This is the generic "I couldn't find a server to talk to" failure. It looks like the above when TCP/IP communication is attempted. A common mistake is to forget the -i option to allow the postmaster to accept TCP/IP connections.
Alternatively, you'll get this when attempting Unix-socket communication to a local postmaster:
psql: could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
The last line is useful in verifying that the client is trying to connect where it is supposed to. If there is in fact no postmaster running there, the kernel error message will typically be either Connection refused or No such file or directory, as illustrated. (It is particularly important to realize that Connection refused in this context does not mean that the postmaster got your connection request and rejected it -- that case will produce a different message

Actual Error Message:
"Connection refused Is the postmaster running (with -i) at 'localhost' and accepting connections on TCP/IP port '5432'?"

POSSIBLE SOLUTION

The rpm distributed with RedHat 7.2 (postgresql-7.1.3-2) does not accept connections by default. Being entirely new to the postgresql world, I'm not sure if this is a bug or feature.

To fix edit /etc/rc.d/init.d/postgresql

Find the line which reads:

su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $Psu -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster start > /dev/null 2>&1" < /dev/null
You must add the -o [options] -i [accept connections] like so:

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

Then issue a
/sbin/service postgresql restart
####
😕

    Do it the easy way. First do:

    locate postgresql.conf

    the edit the postgresql.conf file and change the #tcpip_socket = false line to say tcpip_socket = true. Then do a pg_ctl stop;pg_ctl start and see if you can connect. not connecting by default is a SECURITY feature, not a bug.

      Already tried that method, and it doesn't appear to work either. Appreciate the suggestion, any more idea's you have will be appreciated greatly.

      Hope all is well.

        sorry, but you'll have to give me more info on what you tried than just saying it didn't work. You couldn't find the postgresql.conf file, the database wouldn't shut down, you don't have pg_ctl, you aren't logged in as the postgres user when trying to restart the database, etc...

          Write a Reply...