diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 04124bc254..eda81c1df1 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -354,9 +354,11 @@ WALDumpReadPage(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen,
 					 state->segcxt.ws_segsize);
 
 		if (errinfo.wre_errno != 0)
-			fatal_error("could not read in file %s, offset %u, length %zu: %s",
-						fname, errinfo.wre_off, (Size) errinfo.wre_req,
-						strerror(errinfo.wre_errno));
+		{
+			errno = errinfo.wre_errno;
+			fatal_error("could not read in file %s, offset %u, length %zu: %m",
+						fname, errinfo.wre_off, (Size) errinfo.wre_req);
+		}
 		else
 			fatal_error("could not read in file %s, offset %u: length: %zu",
 						fname, errinfo.wre_off, (Size) errinfo.wre_req);
