diff --git a/contrib/uuid-ossp/uuid-ossp.c b/contrib/uuid-ossp/uuid-ossp.c
index 3e12bc4e96fc422052609dcf7f43c07218786fe5..5d00f392cccb4649e2f7024ddab2f31b7ebf9d0c 100644
--- a/contrib/uuid-ossp/uuid-ossp.c
+++ b/contrib/uuid-ossp/uuid-ossp.c
@@ -17,6 +17,10 @@
 #include "utils/builtins.h"
 #include "utils/uuid.h"
 
+/* for ntohl/htonl */
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
 /*
  * It's possible that there's more than one uuid.h header file present.
  * We expect configure to set the HAVE_ symbol for only the one we want.