Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

postgresql port 5432 connection issue..please help! 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
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 &quot;/usr/bin/pg_ctl -D $Psu -l postgres -s /bin/sh -c &quot;/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster start > /dev/null 2>&1&quot; < /dev/null
You must add the -o [options] -i [accept connections] like so:

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

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

Thanks for your help, and taking the time to read the message..cheers.!
 
whoever you are ,I am grateful
I was stuck on this problem for 4 weeks
 
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: &quot;War is Peace&quot; -- Big Business: &quot;Trust is Suspicion&quot;
(
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top