When working with MicroPython on small microcontrollers like the ESP8266 or ESP32, you quickly hit a wall if you try to do anything with DNS—especially mDNS (multicast DNS). I found out the hard way while building a Bluetooth beacon-powered app that needed to talk to a local server on the same network.
The Problem with micropython-mdns
There’s a package on PyPI called micropython-mdns, but don’t be fooled—this isn’t something that runs on your device. It’s a build utility meant for working with MicroPython code on your desktop. Trying to mip.install("mdns") doesn’t work, and even if you manage to hack something together, you'll face:
Incomplete installs
Memory constraints
Missing socket support
Vague or outdated documentation
In short, DNS support on MicroPython is a mess.
Why This Matters
Many modern apps, especially in IoT or edge scenarios, rely on some form of local device discovery. Whether you’re running a simple HTTP server on your ESP or trying to expose endpoints dynamically, DNS or mDNS is the typical go-to.
But for small micros, this just isn't an option today—not without going native (C/C++) or using an external helper.
My Approach
For now, I’ve pivoted to using dummy data just to prove my app’s concept. The ESP was only acting as a local server—I could use my laptop instead, but I want this system to be portable, low-power, and eventually headless.
That’s why I’ve decided to build my own DNS responder written in C or Rust—tailored for use in embedded projects. It will:
Be lightweight and memory-safe
Run on small MCUs
Support basic A record responses and mDNS
Help other devs avoid the same rabbit hole
Conclusion
This isn’t just a personal fix, it’s something the MicroPython community sorely needs. Reliable, plug-and-play DNS discovery for embedded devices is long overdue. If you’ve been burned trying to get DNS working on a tiny board, stay tuned.
I’ll open-source the DNS tool and write a follow-up on how it works internally once it's ready.
— Kiprono