Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

postgresql port 5432 connection issue..please help!

postgresql port 5432 connection issue..please help!

postgresql port 5432 connection issue..please help!


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!!  



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'?"


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

Thanks for your help, and taking the time to read the message..cheers.!

RE: postgresql port 5432 connection issue..please help!

whoever you are ,I am grateful
I was stuck on this problem for 4 weeks

RE: postgresql port 5432 connection issue..please help!

See my response to newbiepg's post: you need to modify the pg_hba.conf file, usually located at /usr/local/pgsql/data


Big Brother: "War is Peace" -- Big Business: "Trust is Suspicion"

RE: postgresql port 5432 connection issue..please help!

Well this is the complete cycle

This is for redhat linux 7.3 (and possibly 7.2)

change the /etc/init.d/rc.d/postgresql as specified by blaze454. The changes need to be done on line 151.

Then go to /var/lib/pgsql/data/pg_hba.conf file. Uncomment the two lines that allows access for localhost.

Then go to the command line as root , type
1)su postgres
2)psql databasename
3)grant all privileges on tablename to apache

After this restart the postgresql service.
I restarted apache as well.

The php postgresql connection worked fine

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close