5

This process (mdnsd) had been draining my battery for a few weeks. I have not been able to find a solution after a lot of search.

I don't have any drone app, Facebook app or Firefox, although it's true the issue started more or less when I installed the Firefox app. But I have uninstalled it, rebooted my phone and the issue is still there which makes me think Firefox maybe didn't have anything to do with this.

Any ideas? I have an LG G2, Android 4.4.2

2
  • How to you see the process list (via an app - which one; or via command-line - adb/termux)?
    – Robert
    May 30, 2019 at 11:38
  • @Robert I just see it from the default battery usage feature of my phone
    – Damaru
    Jun 3, 2019 at 15:18

2 Answers 2

4

WHAT IS MDNSD:

mdnsd (Multicast Domain Name System Daemon) is Android's implementation of mDNSResponder, a part of upcoming Zero Configuration Networking. It allows you to automatically discover services and appliances attached to your network:

  • Name-to-address translation and other DNS-like operations (mDNS) in the absence of a conventional unicast DNS server:

    It provides the ability for the user to identify hosts using names instead of dotted-decimal IP addresses, even if the user doesn't have a conventional DNS server set up.

  • Network Service discovery (DNS-SD):

    It also provides the ability for the user to discover what services are being advertised on the network, without having to know about them in advance, or configure the machines.

This daemon is continuously sending multicast broadcasts (queries / advertisement) to all hosts on local network at IP address 224.0.0.251 and UDP port 5353, also listening on the same port.

WHICH APPS USE MDNS:

Any app that makes use of Android's Network Service Discovery, will request mdnsd running in background (1, 2, 3):

Adding NSD to your app allows your users to identify other devices on the local network that support the services your app requests. This is useful for a variety of peer-to-peer applications such as file sharing or multi-player gaming.

A quick search on forums will show many apps being blamed for excessive battery drainage becuase of using mdnsd, e.g. Facebook and Firefox. The later has been gone through a bug in the past that caused the unexpected behavior. Now they have their own implementation of MDNS (4). Google Play Services also have built-in MDNS service (to discover Google Cast receiver devices like Chromecast) (5, 6).

Devices that support NSD include printers, webcams, HTTPS servers, and other mobile devices.

AOSP's built-in apps Print Service Recommendation Service (com.android.printservice.recommendation) and Default Print Service (com.android.bips) also make use of NSD. So if you are using printing features on your device, those would be causing mdnsd run in background. But the most common reason is ADBD (Android Debug Bridging Daemon) which force starts mdnsd (7).

HOW TO STOP MDNSD?

mdnsd is an init service (8) which can be stopped by triggers. Add a few lines to /etc/init/mdnsd.rc:

# stop mdnsd on startup
on property:sys.boot_completed=1
    stop mdnsd

# stop mdnsd when adbd starts/stops
on property:init.svc.adbd=*
    stop mdnsd

You can also manually stop the service anytime by executing:

~# setprop ctl.stop mdnsd

Or you can directly kill the mdnsd program as suggested by @DBX12. The service shouldn't restart because it's oneshot. But if it's triggered again and again by some app or the OS, you can make the binary inexecutable (or delete) at all:

~# chmod a-x /system/bin/mdnsd

However this may break some apps' functionality.

All of the above solutions require root. If your device isn't rooted, the only way is to identify and stop using the app/feature that uses Android's NSD API or directly starts mdnsd service.

4
  • I guess I'll have to root my phone. I have tried to identify the app but I couldn't, after playing a lot with uninstalling things
    – Damaru
    Jun 20, 2019 at 20:07
  • Did you stop UDB Debugging from Developer Options and restart device? May be it's the ADB starting mdnsd at startup. Once started, it won't stop even if you stop ADB later on. Jun 21, 2019 at 2:11
  • Yes, I had done that
    – Damaru
    Jun 22, 2019 at 8:28
  • May be you have set persist.sys.usb.config=adb in your /default.prop. Jun 22, 2019 at 10:25
3

It seems like it is the daemon for multicast DNS. I have the same issue as OP and Trevor. My solution is the following (assuming you have a rooted device). If you have adb, then do step 2 over that, it is more comfortable to type on a keyboard ;)

  1. Install a Terminal Emulator
  2. Create a shellscript with the content su -c "kill $(pgrep mdnsd)"
  3. Run it everytime you see fast battery drainage as this is a symptom of a running mdnsd. Confirm the prompt of SuperSU to grant root permissions to the script.

What the script does:

su -c "kill $(pgrep mdnsd)"
^      ^    ^ ^
|      |    | |
|      |    | +- Search the process list for the phrase "mdnsd" and return the process id
|      |    |
|      |    +- Spawn a subshell and execute contained command and return its output
|      |
|      +- Stop the process with the process id specified after kill
+- run the command specified after -c with superuser privileges
3
  • Needless to say, it requires a working "su" binary, meaning you need a rooted phone.
    – peterh
    Oct 6, 2021 at 0:24
  • @peterh well, I put that requirement in the second sentence in bold ;)
    – DBX12
    Oct 13, 2021 at 8:02
  • 1
    Oops, thx, dbx! :-)
    – peterh
    Oct 13, 2021 at 9:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .