diff --git a/src/zeroconf/ZeroconfAvahi.cxx b/src/zeroconf/ZeroconfAvahi.cxx
index 30f39697f..d50aae820 100644
--- a/src/zeroconf/ZeroconfAvahi.cxx
+++ b/src/zeroconf/ZeroconfAvahi.cxx
@@ -24,7 +24,6 @@
 #include "avahi/Publisher.hxx"
 #include "avahi/Service.hxx"
 #include "ZeroconfInternal.hxx"
-#include "Listen.hxx"
 #include "util/Domain.hxx"
 #include "util/RuntimeError.hxx"
 #include "Log.hxx"
@@ -55,7 +54,7 @@ public:
 static AvahiGlue *avahi_glue;
 
 void
-AvahiInit(EventLoop &loop, const char *serviceName)
+AvahiInit(EventLoop &loop, const char *serviceName, unsigned port)
 {
 	LogDebug(avahi_domain, "Initializing interface");
 
@@ -65,7 +64,7 @@ AvahiInit(EventLoop &loop, const char *serviceName)
 	std::forward_list<Avahi::Service> services;
 	services.emplace_front(AVAHI_IF_UNSPEC,
 			       AVAHI_PROTO_UNSPEC,
-			       SERVICE_TYPE, listen_port);
+			       SERVICE_TYPE, port);
 
 	avahi_glue = new AvahiGlue(loop, serviceName, std::move(services));
 }
diff --git a/src/zeroconf/ZeroconfAvahi.hxx b/src/zeroconf/ZeroconfAvahi.hxx
index f5b198e4e..684098426 100644
--- a/src/zeroconf/ZeroconfAvahi.hxx
+++ b/src/zeroconf/ZeroconfAvahi.hxx
@@ -23,7 +23,7 @@
 class EventLoop;
 
 void
-AvahiInit(EventLoop &loop, const char *service_name);
+AvahiInit(EventLoop &loop, const char *service_name, unsigned port);
 
 void
 AvahiDeinit();
diff --git a/src/zeroconf/ZeroconfBonjour.cxx b/src/zeroconf/ZeroconfBonjour.cxx
index 170df046f..ba6cd63e2 100644
--- a/src/zeroconf/ZeroconfBonjour.cxx
+++ b/src/zeroconf/ZeroconfBonjour.cxx
@@ -19,7 +19,6 @@
 
 #include "ZeroconfBonjour.hxx"
 #include "ZeroconfInternal.hxx"
-#include "Listen.hxx"
 #include "event/SocketEvent.hxx"
 #include "util/Domain.hxx"
 #include "Log.hxx"
@@ -84,13 +83,13 @@ dnsRegisterCallback([[maybe_unused]] DNSServiceRef sdRef,
 }
 
 void
-BonjourInit(EventLoop &loop, const char *service_name)
+BonjourInit(EventLoop &loop, const char *service_name, unsigned port)
 {
 	DNSServiceRef dnsReference;
 	DNSServiceErrorType error = DNSServiceRegister(&dnsReference,
 						       0, 0, service_name,
 						       SERVICE_TYPE, nullptr, nullptr,
-						       htons(listen_port), 0,
+						       htons(port), 0,
 						       nullptr,
 						       dnsRegisterCallback,
 						       nullptr);
diff --git a/src/zeroconf/ZeroconfBonjour.hxx b/src/zeroconf/ZeroconfBonjour.hxx
index 3c6f0c8f4..6bbc85b8b 100644
--- a/src/zeroconf/ZeroconfBonjour.hxx
+++ b/src/zeroconf/ZeroconfBonjour.hxx
@@ -23,7 +23,7 @@
 class EventLoop;
 
 void
-BonjourInit(EventLoop &loop, const char *service_name);
+BonjourInit(EventLoop &loop, const char *service_name, unsigned port);
 
 void
 BonjourDeinit();
diff --git a/src/zeroconf/ZeroconfGlue.cxx b/src/zeroconf/ZeroconfGlue.cxx
index 9e69ba0ec..da84e3758 100644
--- a/src/zeroconf/ZeroconfGlue.cxx
+++ b/src/zeroconf/ZeroconfGlue.cxx
@@ -82,11 +82,11 @@ ZeroconfInit(const ConfigData &config, [[maybe_unused]] EventLoop &loop)
 	}
 
 #ifdef HAVE_AVAHI
-	AvahiInit(loop, serviceName);
+	AvahiInit(loop, serviceName, listen_port);
 #endif
 
 #ifdef HAVE_BONJOUR
-	BonjourInit(loop, serviceName);
+	BonjourInit(loop, serviceName, listen_port);
 #endif
 }
 
diff --git a/test/run_avahi.cxx b/test/run_avahi.cxx
index 547f8abdc..c41c90ca2 100644
--- a/test/run_avahi.cxx
+++ b/test/run_avahi.cxx
@@ -23,15 +23,13 @@
 
 #include <stdlib.h>
 
-unsigned listen_port = 1234;
-
 int
 main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
 {
 	EventLoop event_loop;
 	const ShutdownHandler shutdown_handler(event_loop);
 
-	AvahiInit(event_loop, "test");
+	AvahiInit(event_loop, "test", 1234);
 
 	event_loop.Run();