Skip to content

ESP32 mDNS Query Returns No Results

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 mDNS Query Returns No Results. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 queries mDNS for other devices on the network but finds nothing.

Quick Fix

Wrong

int n = MDNS.queryService("http", "tcp");
if (n == 0) Serial.println("No services found");
No services found (but other devices are online and advertising mDNS).
MDNS.addService("http", "tcp", 80);
delay(2000);
int n = MDNS.queryService("http", "tcp");
Serial.printf("Found %d services\n", n);
for (int i = 0; i < n; i++) {
  Serial.printf("%s:%d\n", MDNS.hostname(i).c_str(), MDNS.port(i));
}
Found 2 services
raspberrypi.local:80
server-room.local:3000

Prevention

Wait 2 seconds after starting mDNS before querying. Use exact service type and protocol. Verify target devices have mDNS enabled. Check that both devices are on the same VLAN/subnet.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### How long does mDNS discovery take?

mDNS queries wait 2-5 seconds for responses. The ESP32 queryService() uses a default timeout of 2 seconds.

Can mDNS resolve hostnames other than services?

Yes. Use MDNS.queryHost("hostname.local") to resolve any mDNS hostname to an IP address.

What limits mDNS reliability?

mDNS is affected by network congestion, switches that block multicast, and firewalls. 802.11 power saving on Wi-Fi can delay responses.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro