Обсуждение: TCP only listening on localhost???

Поиск
Список
Период
Сортировка

TCP only listening on localhost???

От
Richard Gass
Дата:
First weird problem...
The other day, out of the blue, our application reported an error saying it
could not connect to the postgres db.  The hostname that it reported is the
name of the machine but it hasn't been used in awhile.  However, it does
have a valid cname entry in dns pointing to the correct host.  I added the
name in the /etc/hosts file on the server and the problem was fixed.

Next weird problem...
I recently upgraded a few nodes that connect to the server to Redhat 9.  I
installed all the necessary rpm's and when I tried to connect to the remote
server, I get the following error.

# psql -U postgres -d dbname -h server_name
psql: could not connect to server: Connection refused
        Is the server running on host server_name and accepting
        TCP/IP connections on port 5432?

Here is the output of netstat -ae | grep tcp | grep LIST

...
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN

tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN

tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN

...

As you can see, postgres is listening on localhost put not "0.0.0.0:5432" as
I see in many posts to this site.  This was working fine before but now I
cannot connect from any other server that I have given permission to in
pg_hba.conf.
local   all         all                                             trust
host    all         all         127.0.0.1         255.255.255.255   trust
host    all         all         10.64.228.10      255.255.255.255   trust
host    all         all         10.64.228.112     255.255.255.255   trust
host    all         all         10.64.228.115     255.255.255.255   trust

And Yes I have the "-i" option specified in my postmaster command...
/usr/local/db/pgsql/bin/postmaster -i -c log_connections=on -h server_name
-D /usr/local/db/pgsql/data

and Yes I have tcpip_socket = true in postgresql.conf.

No, I do not have multiple installs of postgres on this system and I am sure
they are using the correct configuration files.

This was all working fine until I recently.  It has been a long time since I
have restarted the server (  5:05pm  up 377 days, 18:36,  7 users,  load
average: 0.00, 0.00, 0.00) and it has been a long time since I restarted the
postgres DB.  I wonder if some weirdness is happening which isn't allowing
postgres to bind to tcp port 5432.

From the server...  This is connecting through the socket...
# psql -h server_name -U postgres -d dbname
Welcome to psql 7.3.2, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

dbname=# \q
From the server...  This is trying to connect to the port...
# psql -h 10.64.228.10 -U postgres -d dbname
psql: could not connect to server: Connection refused
        Is the server running on host 10.64.228.10 and accepting
        TCP/IP connections on port 5432?

Any ideas what could be happening?

Thanks

Richard


Re: TCP only listening on localhost???

От
Tom Lane
Дата:
Richard Gass <rgass@sprintlabs.com> writes:
> This was all working fine until I recently.  It has been a long time since I
> have restarted the server (  5:05pm  up 377 days, 18:36,  7 users,  load
> average: 0.00, 0.00, 0.00) and it has been a long time since I restarted the
> postgres DB.  I wonder if some weirdness is happening which isn't allowing
> postgres to bind to tcp port 5432.

This seems really really odd.  Have you touched the machine's firewall
configuration (iptables or whatever) lately?

            regards, tom lane

Re: TCP only listening on localhost???

От
Richard Gass
Дата:
There are no firewalling issues, routing or dns issues.  Basically nothing
has changed with the server.  The only change is with the clients that
connect.  Everything seems to work fine connecting from the local socket but
when you try to connect over tcp, it doesn't work because it is not
listening on the port.  For some reason, I cannot get it to listen on the
port unless I specify in my postmaster command -h ip.address.

I am using postgres 7.3.2 on redhat 7.1 on the server.  On the clients, it
is RH9.0 with the same postgres version installed from a tarball.

I bet if I reboot the machine, everything will work but I don't want to lose
my uptime:-)



-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thursday, April 29, 2004 9:35 PM
To: Richard Gass
Cc: 'pgsql-general@postgresql.org'
Subject: Re: [GENERAL] TCP only listening on localhost???


Richard Gass <rgass@sprintlabs.com> writes:
> This was all working fine until I recently.  It has been a long time
> since I have restarted the server (  5:05pm  up 377 days, 18:36,  7
> users,  load
> average: 0.00, 0.00, 0.00) and it has been a long time since I restarted
the
> postgres DB.  I wonder if some weirdness is happening which isn't allowing
> postgres to bind to tcp port 5432.

This seems really really odd.  Have you touched the machine's firewall
configuration (iptables or whatever) lately?

            regards, tom lane

Re: TCP only listening on localhost???

От
Alvaro Herrera
Дата:
On Fri, Apr 30, 2004 at 09:26:48AM -0700, Richard Gass wrote:
> There are no firewalling issues, routing or dns issues.  Basically nothing
> has changed with the server.  The only change is with the clients that
> connect.  Everything seems to work fine connecting from the local socket but
> when you try to connect over tcp, it doesn't work because it is not
> listening on the port.  For some reason, I cannot get it to listen on the
> port unless I specify in my postmaster command -h ip.address.

Maybe the virtual_host parameter has changed?  Somehow the postmaster is
not binding to the interface, and if it works when you specify manually
then certainly seems a config problem.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"La experiencia nos dice que el hombre peló millones de veces las patatas,
pero era forzoso admitir la posibilidad de que en un caso entre millones,
las patatas pelarían al hombre" (Ijon Tichy)