psql connection timeout

Started by John DeSoiover 21 years ago4 messagesgeneral
Jump to latest
#1John DeSoi
desoi@pgedit.com

Is there a way to control how long psql waits for a connection? If the
host IP address is mistyped, psql (8.0b4) hangs for over a minute on OS
X.

Thanks,

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL

#2Michael Fuhr
mike@fuhr.org
In reply to: John DeSoi (#1)
Re: psql connection timeout

On Thu, Dec 02, 2004 at 11:32:34PM -0500, John DeSoi wrote:

Is there a way to control how long psql waits for a connection? If the
host IP address is mistyped, psql (8.0b4) hangs for over a minute on OS
X.

Try setting the PGCONNECT_TIMEOUT environment variable:

env PGCONNECT_TIMEOUT=5 psql -h bogushost

If you always want to use a particular timeout then set the environment
variable in your shell's startup script.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#3John DeSoi
desoi@pgedit.com
In reply to: Michael Fuhr (#2)
Re: psql connection timeout

Hi Michael,

On Dec 2, 2004, at 11:53 PM, Michael Fuhr wrote:

Try setting the PGCONNECT_TIMEOUT environment variable:

env PGCONNECT_TIMEOUT=5 psql -h bogushost

This works great -- thanks very much.

I did not see this anywhere in the documentation. Did I miss it or is
the source code the only reference point?

Best,

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL

#4Bruce Momjian
bruce@momjian.us
In reply to: John DeSoi (#3)
Re: psql connection timeout

John DeSoi wrote:

Hi Michael,

On Dec 2, 2004, at 11:53 PM, Michael Fuhr wrote:

Try setting the PGCONNECT_TIMEOUT environment variable:

env PGCONNECT_TIMEOUT=5 psql -h bogushost

This works great -- thanks very much.

I did not see this anywhere in the documentation. Did I miss it or is
the source code the only reference point?

I see it mentioned in the libpq section of the manual. Those variables
actually affect all applications that use libpq, including psql.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073