Re: Postgres intermittent connection errors: psql.bin: could not connect to server: Cannot assign requested address

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vamsi Patchipulusu <vpatchipulusu(at)equinix(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, Danjue Li <danli(at)equinix(dot)com>, Rashmi Panthangi <rpanthangi(at)equinix(dot)com>, Lakshmi Yarlagadda <lyarlagadda(at)equinix(dot)com>
Subject: Re: Postgres intermittent connection errors: psql.bin: could not connect to server: Cannot assign requested address
Date: 2017-05-16 06:29:26
Message-ID: 30038.1494916166@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vamsi Patchipulusu <vpatchipulusu(at)equinix(dot)com> writes:
> Error: psql.bin: could not connect to server: Cannot assign requested address
> Is the server running on host "abchost.corp.xyz.com" (xxx.xxx.xxx.xxx) and accepting
> TCP/IP connections on port 5432?

Googling suggests that this could occur if you're recycling client-side
connections so fast that the old port number assignments haven't timed out
yet. That's not a Postgres bug, it's inherent in the TCP protocol specs.

> The shell script does the following:
> a) Connects to postgres database server using psql.
> b) Issues a single select statement on table with 200 rows .
> c) Writes the results to a text file.

There is a large body of evidence to the effect that issuing only one
query per connection attempt is a performance-killer. Don't do that, at
least not more often than you have to. This particular symptom is a new
one on me, but there are lots of other reasons not to do it.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Devrim Gündüz 2017-05-16 08:00:53 Re: Help: Installing 9.6 breaks local connections to 9.2 on Centos 6.9
Previous Message David G. Johnston 2017-05-16 06:00:56 Re: Postgres intermittent connection errors: psql.bin: could not connect to server: Cannot assign requested address