Thread: Postgres does not accept socket connections
Hi All, I have the following problem. I am able to access a PostgreSQL database only as "localhost". If I try to open psql from a different machine with -h option, then I get the following error message. The database resides on a server running Fedora Core 4 and PostgreSQL 8.1.1 server. I am trying to access the database from another server running RedHat 9 and PostgreSQL 7.3.2. Command psql -U postgres -h server-name database-name Error psql: could not connect to server: Connection refused Is the server running on host "server-name" and accepting TCP/IP connections on port 5432? Similarly, I am unable to access the database using PHP's postgres API, with the host set as "server-name". However, I am able to locally access if I specify host as "localhost". I need the PostgreSQL server on the machine which contains the database to accept socket connections. Any help in this regard will be appreciated. Thanks in advance - Kishore
After a long battle with technology, kishore.sainath@gmail.com, an earthling, wrote: > I need the PostgreSQL server on the machine which contains the database > to accept socket connections. > Any help in this regard will be appreciated. Look for the configuration file postgresql.conf. It is doubtless set up to only accept local connections. That is the default configuration, and represents a decent default security measure. Look in that file for a variable called "listen_addresses." You'll doubtless find it commented out. The suggested value is "*", that is, to accept connections coming to all IP interfaces. That's probably what you want to change it to. Restart the database (reloading config won't suffice, I don't think). You should have remote access. You may then get complaints that pg_hba.conf won't admit the connections; that file is in the same directory. If you change it, you need only reload PostgreSQL configuration; you don't need to restart the database... -- (reverse (concatenate 'string "moc.liamg" "@" "enworbbc")) http://linuxdatabases.info/info/slony.html REALITY is a policy phased out early in the Eisenhower administration.
am 02.03.2006, um 4:37:02 -0800 mailte kishore.sainath@gmail.com folgendes: > Hi All, > > I have the following problem. > > I am able to access a PostgreSQL database only as "localhost". If I try > to open psql from a different machine with -h option, then I get the > following error message. > > The database resides on a server running Fedora Core 4 and PostgreSQL > 8.1.1 server. > I am trying to access the database from another server running RedHat 9 > and PostgreSQL 7.3.2. > > Command > psql -U postgres -h server-name database-name > > Error > psql: could not connect to server: Connection refused > Is the server running on host "server-name" and accepting > TCP/IP connections on port 5432? Check the postgresql.conf for the value "listen_addresses". My guess: listen_address is at the moment 'localhost'. Change this to the LAN-address or '*'. Read also the pg_hba.conf - file! http://www.postgresql.org/docs/current/static/client-authentication.html#AUTH-PG-HBA-CONF HTH, Andreas -- Andreas Kretschmer (Kontakt: siehe Header) Heynitz: 035242/47215, D1: 0160/7141639 GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net === Schollglas Unternehmensgruppe ===
"A. Kretschmer" <andreas.kretschmer@schollglas.com> writes: > am 02.03.2006, um 4:37:02 -0800 mailte kishore.sainath@gmail.com folgendes: >> psql: could not connect to server: Connection refused >> Is the server running on host "server-name" and accepting >> TCP/IP connections on port 5432? > Check the postgresql.conf for the value "listen_addresses". > My guess: listen_address is at the moment 'localhost'. Change this to > the LAN-address or '*'. If listen_addresses is correct and you still get "Connection refused", the other thing to look at is the kernel's packet filtering rules (iptables). I believe the default configuration on FC4 will reject external connections to 5432. regards, tom lane