*** a/src/backend/replication/walsender.c
--- b/src/backend/replication/walsender.c
***************
*** 119,124 **** WalSenderMain(void)
--- 119,130 ----
  				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
  				 errmsg("must be superuser to start walsender")));
  
+ 	if (RecoveryInProgress())
+ 		ereport(FATAL,
+ 				(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ 				 errmsg("recovery is in progress"),
+ 				 errhint("cannot accept the standby server during recovery.")));
+ 
  	/* Create a per-walsender data structure in shared memory */
  	InitWalSnd();
  
