diff --git a/src/zeroconf/ZeroconfGlue.cxx b/src/zeroconf/ZeroconfGlue.cxx
index 2514e6b86..a6c9bf6fa 100644
--- a/src/zeroconf/ZeroconfGlue.cxx
+++ b/src/zeroconf/ZeroconfGlue.cxx
@@ -32,6 +32,12 @@
 #include <unistd.h>
 #include <limits.h>
 
+#ifndef HOST_NAME_MAX
+/* HOST_NAME_MAX is not a portable macro; it is undefined on some
+   systems */
+#define HOST_NAME_MAX 255
+#endif
+
 static constexpr Domain zeroconf_domain("zeroconf");
 
 /* The default service name to publish