ESP32 mDNS Not Working
Resolve issues where the ESP32's `.local` hostname is not accessible on the network, despite enabling mDNS in code.
Common Causes
- 🌐
mDNS Not Supported by Network
Some routers or network environments block or do not forward multicast DNS packets, preventing
.local
resolution. - 🔧
mDNS Not Started in Code
If
MDNS.begin("esp32")
is missing or placed before Wi-Fi is connected, the service will not be advertised. - 🧯
Firewall or Antivirus Blocking mDNS
Host systems like Windows or macOS may have firewall rules preventing inbound mDNS responses on port 5353.
- 📱
Mobile Hotspot or Guest Network Limitations
Some AP modes, hotspots, or guest Wi-Fi networks isolate clients and block multicast traffic like mDNS.
Symptoms
`esp32.local` Not Found in Browser or Ping
Attempting to access http://esp32.local/
fails, even though the ESP32 is on the same network.
IP Address Works But Hostname Does Not
The ESP32 can be reached via its IP, but .local
name fails to resolve.
Works on One Computer, Not Another
Some systems resolve mDNS properly while others do not, often due to OS-level differences or missing service discovery tools.
Bonjour or Avahi Not Running
On systems without built-in mDNS support (Linux, Windows), required background services may be missing or stopped.
Solutions
Ensure `MDNS.begin()` is Called After Wi-Fi Connects
Initialize mDNS after a successful connection by placing MDNS.begin("esp32")
inside the Wi-Fi connected event.
Install Bonjour (Windows) or Avahi (Linux)
Add or enable mDNS client tools on your computer to support .local
resolution across platforms.
Use IP Address as Fallback
If mDNS isn’t reliable, use WiFi.localIP()
to get the device’s IP and communicate directly.
Avoid Guest or Hotspot Networks
Use a regular LAN where clients can discover each other via multicast; avoid guest isolation or client separation features.
More Details
ESP32 mDNS Not Working #
You're trying to access your ESP32 via http://esp32.local
, but the browser says “server not found” or ping fails. Yet when you type in the IP address directly (e.g., http://192.168.1.104
), everything works.
This is a sign that multicast DNS (mDNS) — the system that makes .local
names work — isn't functioning correctly on your network or device. This guide will help you understand how ESP32 mDNS works and what to do when it fails.
What Is mDNS? #
Multicast DNS lets devices on a local network resolve names like esp32.local
without a central DNS server. It uses multicast traffic on port 5353, and is often used in LANs for discovery of IoT devices, printers, etc.
ESP32 supports mDNS via the ESPmDNS
library. In code:
#include <ESPmDNS.h>
if (!MDNS.begin("esp32")) {
Serial.println("Error starting mDNS");
}
This should make esp32.local
reachable — but only if the network and your host system allow it.
Common Symptoms of Broken mDNS #
esp32.local
Fails to Resolve #
You can ping the ESP32’s IP directly but:
ping esp32.local
results in Host not found
.
Only Some Devices Work #
mDNS may work on one laptop (e.g., a MacBook) but not on another (e.g., Windows PC), indicating OS-level or service differences.
Works with IP Address, Not Hostname #
All functions via IP (HTTP, OTA, etc.) work perfectly, but .local
never resolves. This is common on Windows if Bonjour is missing.
Root Causes and Fixes #
🧯 MDNS Not Initialized Correctly #
MDNS.begin()
must be called after the ESP32 connects to Wi-Fi:
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
MDNS.begin("esp32");
If it runs too early (before network stack is up), it silently fails.
🔒 Bonjour or Avahi Not Installed #
On Windows, mDNS requires Apple Bonjour (bundled with iTunes or available standalone).
On Linux, install avahi-daemon
and nss-mdns
:
sudo apt install avahi-daemon libnss-mdns
macOS has built-in mDNS support via Bonjour.
🌐 Network Doesn’t Allow Multicast #
Many guest Wi-Fi networks or mobile hotspots block client-to-client traffic or multicast packets.
Fixes:
Use a home router, not a phone hotspot
Disable “AP Isolation” in router settings
Ensure all devices are on the same subnet
🛡 Firewall Blocking Port 5353 #
On some systems, firewalls block inbound or outbound UDP packets on port 5353. Check firewall rules or try temporarily disabling them to test.
Workarounds and Alternatives #
- Print the IP in Serial Monitor and use it:
Serial.println(WiFi.localIP());
Use a captive portal or MQTT broker with a fixed IP instead of relying on mDNS.
For production, consider using a static IP or fallback to DHCP-assigned IP discovery via a known endpoint.
Conclusion #
mDNS on ESP32 is a powerful feature, but it depends on:
Correct timing in your firmware
Host OS support (Bonjour, Avahi)
Network policies allowing multicast
If esp32.local
isn’t working, check the basics:
Is
MDNS.begin()
called after Wi-Fi connects?Does your OS support mDNS?
Are you on a network that allows local discovery?
With the right setup, mDNS can make your ESP32 discoverable instantly on any local network — no IP memorization required.

Quick Navigation
Additional Resources
Still Stuck with an ESP32 Issue? Let's solve it together.
Our interactive troubleshooting wizard will guide you through common ESP32 problems and their solutions, step by step.