diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 0dda180..0e3a17b 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -2989,6 +2989,13 @@ keep_going:						/* We will come back to here until there is
 						goto error_return;
 					}
 					PQclear(res);
+
+					/* Keep reading until PQgetResult returns NULL */
+					conn->status = CONNECTION_CHECK_WRITABLE;
+					goto keep_going;
+				}
+				else if (res == NULL)
+				{
 					termPQExpBuffer(&savedMessage);
 
 					/* We can release the address lists now. */
