diff --git a/doc/src/sgml/ref/pg_isready.sgml b/doc/src/sgml/ref/pg_isready.sgml
new file mode 100644
index ea0d3a7..ff80a78
*** a/doc/src/sgml/ref/pg_isready.sgml
--- b/doc/src/sgml/ref/pg_isready.sgml
*************** PostgreSQL documentation
*** 97,102 ****
--- 97,114 ----
       </varlistentry>
  
       <varlistentry>
+        <term><option>-t <replaceable class="parameter">seconds</replaceable></></term>
+        <term><option>--timeout=<replaceable class="parameter">seconds</replaceable></></term>
+        <listitem>
+        <para>
+         The maximum number of seconds to wait when attempting connection before
+         returning that the server is not responding. Setting to 0 disables. The
+         default is 3 seconds.
+        </para>
+        </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
         <term><option>-U <replaceable class="parameter">username</replaceable></></term>
         <term><option>--username=<replaceable class="parameter">username</replaceable></></term>
         <listitem>
diff --git a/src/bin/scripts/pg_isready.c b/src/bin/scripts/pg_isready.c
new file mode 100644
index feee1a7..56d1ddd
*** a/src/bin/scripts/pg_isready.c
--- b/src/bin/scripts/pg_isready.c
***************
*** 12,17 ****
--- 12,19 ----
  #include "postgres_fe.h"
  #include "common.h"
  
+ #define	DEFAULT_CONNECT_TIMEOUT "3"
+ 
  static void
  help(const char *progname);
  
*************** main(int argc, char **argv)
*** 26,33 ****
  	const char *pgport = NULL;
  	const char *pguser = NULL;
  	const char *pgdbname = NULL;
  
! 	const char *keywords[4], *values[4];
  
  	bool quiet = false;
  
--- 28,37 ----
  	const char *pgport = NULL;
  	const char *pguser = NULL;
  	const char *pgdbname = NULL;
+ 	const char *connect_timeout = DEFAULT_CONNECT_TIMEOUT;
  
! 	const char *keywords[6] = { NULL };
! 	const char *values[6] = { NULL };
  
  	bool quiet = false;
  
*************** main(int argc, char **argv)
*** 44,49 ****
--- 48,54 ----
  			{"host", required_argument, NULL, 'h'},
  			{"port", required_argument, NULL, 'p'},
  			{"quiet", no_argument, NULL, 'q'},
+ 			{"timeout", required_argument, NULL, 't'},
  			{"username", required_argument, NULL, 'U'},
  			{NULL, 0, NULL, 0}
  		};
*************** main(int argc, char **argv)
*** 51,57 ****
  	progname = get_progname(argv[0]);
  	handle_help_version_opts(argc, argv, progname, help);
  
! 	while ((c = getopt_long(argc, argv, "d:h:p:qU:V", long_options, &optindex)) != -1)
  	{
  		switch (c)
  		{
--- 56,62 ----
  	progname = get_progname(argv[0]);
  	handle_help_version_opts(argc, argv, progname, help);
  
! 	while ((c = getopt_long(argc, argv, "d:h:p:qt:U:V", long_options, &optindex)) != -1)
  	{
  		switch (c)
  		{
*************** main(int argc, char **argv)
*** 67,72 ****
--- 72,80 ----
  			case 'q':
  				quiet = true;
  				break;
+ 			case 't':
+ 				connect_timeout = pg_strdup(optarg);
+ 				break;
  			case 'U':
  				pguser = pg_strdup(optarg);
  				break;
*************** main(int argc, char **argv)
*** 92,98 ****
  	}
  
  	/*
! 	 * Get the default options so we can display them in our output
  	 */
  
  	connect_options = PQconndefaults();
--- 100,126 ----
  	}
  
  	/*
! 	 * Set connection options
! 	 */
! 
! 	keywords[opt_index] = "connect_timeout";
! 	values[opt_index] = connect_timeout;
! 	opt_index++;
! 	if (pguser)
! 	{
! 		keywords[opt_index] = "user";
! 		values[opt_index] = pguser;
! 		opt_index++;
! 	}
! 	if (pgdbname)
! 	{
! 		keywords[opt_index] = "dbname";
! 		values[opt_index] = pgdbname;
! 		opt_index++;
! 	}
! 
! 	/*
! 	 * Get the default host and port so we can display them in our output
  	 */
  
  	connect_options = PQconndefaults();
*************** main(int argc, char **argv)
*** 124,157 ****
  			else if (conn_opt_ptr->val)
  				pgport = conn_opt_ptr->val;
  		}
- 		else if (strncmp(conn_opt_ptr->keyword, "user", 5) == 0)
- 		{
- 			if (pguser)
- 			{
- 				keywords[opt_index] = conn_opt_ptr->keyword;
- 				values[opt_index] = pguser;
- 				opt_index++;
- 			}
- 			else if (conn_opt_ptr->val)
- 				pguser = conn_opt_ptr->val;
- 		}
- 		else if (strncmp(conn_opt_ptr->keyword, "dbname", 7) == 0)
- 		{
- 			if (pgdbname)
- 			{
- 				keywords[opt_index] = conn_opt_ptr->keyword;
- 				values[opt_index] = pgdbname;
- 				opt_index++;
- 			}
- 			else if (conn_opt_ptr->val)
- 				pgdbname = conn_opt_ptr->val;
- 		}
  		conn_opt_ptr++;
  	}
  
- 	keywords[opt_index] = NULL;
- 	values[opt_index] = NULL;
- 
  	rv = PQpingParams(keywords, values, 1);
  
  	if (!quiet)
--- 152,160 ----
*************** help(const char *progname)
*** 198,202 ****
--- 201,207 ----
  	printf(_("\nConnection options:\n"));
  	printf(_("  -h, --host=HOSTNAME      database server host or socket directory\n"));
  	printf(_("  -p, --port=PORT          database server port\n"));
+ 	printf(_("  -t, --timeout=SECS       seconds to wait when attempting connection, 0 disables (default: %s)\n"), DEFAULT_CONNECT_TIMEOUT);
  	printf(_("  -U, --username=USERNAME  database username\n"));
+ 	printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
  }
