diff --git a/src/port/dirent.c b/src/port/dirent.c
index 9e1d1317efcf22d0aa5dd13e37ceaeabe1db23b3..6219ccb46947901b4c3da961d1cae5bbe6ff7706 100644
--- a/src/port/dirent.c
+++ b/src/port/dirent.c
@@ -13,7 +13,12 @@
  *-------------------------------------------------------------------------
  */
 
+#ifndef FRONTEND
 #include "postgres.h"
+#else
+#include "postgres_fe.h"
+#endif
+
 #include <dirent.h>
 
 
diff --git a/src/port/pipe.c b/src/port/pipe.c
index 0963cbba78afe9443450a4a3ab74af32c3477af5..95839c6583004f73233b7ed28685847d1b3e2c81 100644
--- a/src/port/pipe.c
+++ b/src/port/pipe.c
@@ -15,7 +15,11 @@
  *-------------------------------------------------------------------------
  */
 
+#ifndef FRONTEND
 #include "postgres.h"
+#else
+#include "postgres_fe.h"
+#endif
 
 #ifdef WIN32
 int
diff --git a/src/port/win32error.c b/src/port/win32error.c
index 5dfb694180422705af4d659cf4daf768f9ba9cb6..4b3b1ea7d6ea189277b9d4945b97b5e9fc3bd5da 100644
--- a/src/port/win32error.c
+++ b/src/port/win32error.c
@@ -11,7 +11,11 @@
  *-------------------------------------------------------------------------
  */
 
+#ifndef FRONTEND
 #include "postgres.h"
+#else
+#include "postgres_fe.h"
+#endif
 
 static const struct
 {