diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index ddc3ec860ae..eb3ca07df71 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3913,6 +3913,9 @@ PostgresMain(int argc, char *argv[],
 		disable_all_timeouts(false);
 		QueryCancelPending = false; /* second to avoid race condition */
 
+		/* Forget about any active statement timeout. */
+		stmt_timeout_active = false;
+
 		/* Not reading from the client anymore. */
 		DoingCommandRead = false;
 
