Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here


Low level multicast-dns implementation in pure javascript

Subscribe to updates I use multicast-dns

Statistics on multicast-dns

Number of watchers on Github 230
Number of open issues 9
Average time to close an issue 8 days
Main language JavaScript
Average time to merge a PR 4 days
Open pull requests 6+
Closed pull requests 3+
Last commit over 1 year ago
Repo Created almost 5 years ago
Repo Last Updated over 1 year ago
Size 72 KB
Organization / Authormafintosh
Page Updated
Do you use multicast-dns? Leave a review!
View open issues (9)
View multicast-dns activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating multicast-dns for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)


Low level multicast-dns implementation in pure javascript

npm install multicast-dns

build status


var mdns = require('multicast-dns')()

mdns.on('response', function(response) {
  console.log('got a response packet:', response)

mdns.on('query', function(query) {
  console.log('got a query packet:', query)

// lets query for an A record for 'brunhilde.local'
    name: 'brunhilde.local',
    type: 'A'

Running the above (change brunhilde.local to your-own-hostname.local) will print an echo of the query packet first

got a query packet: { type: 'query',
  questions: [ { name: 'brunhilde.local', type: 'A', class: 1 } ],
  answers: [],
  authorities: [],
  additionals: [] }

And then a response packet

got a response packet: { type: 'response',
  questions: [],
   [ { name: 'brunhilde.local',
       type: 'A',
       class: 'IN',
       ttl: 120,
       flush: true,
       data: '' } ],
  authorities: [],
   [ { name: 'brunhilde.local',
       type: 'A',
       class: 'IN',
       ttl: 120,
       flush: true,
       data: '' },
     { name: 'brunhilde.local',
       type: 'AAAA',
       class: 'IN',
       ttl: 120,
       flush: true,
       data: 'fe80::5ef9:38ff:fe8c:ceaa' } ] }


npm install -g multicast-dns
multicast-dns brunhilde.local


A packet has the following format

  questions: [{
  answers: [{
    data:(record type specific data)
  additionals: [
    (same format as answers)
  authorities: [
    (same format as answers)

Currently data from SRV, A, PTR, TXT, AAAA and HINFO records is passed

mdns = multicastdns([options])

Creates a new mdns instance. Options can contain the following

  multicast: true // use udp multicasting
  interface: '' // explicitly specify a network interface. defaults to all
  port: 5353, // set the udp port
  ip: '', // set the udp ip
  ttl: 255, // set the multicast ttl
  loopback: true, // receive your own packets
  reuseAddr: true // set the reuseAddr option when creating the socket (requires node >=0.11.13)

mdns.on('query', (packet, rinfo))

Emitted when a query packet is received.

mdns.on('query', function(query) {
  if (query.questions[0] && query.questions[0].name === 'brunhilde.local') {
    mdns.respond(someResponse) // see below

mdns.on('response', (packet, rinfo))

Emitted when a response packet is received.

The response might not be a response to a query you send as this is the result of someone multicasting a response.

mdns.query(packet, [cb])

Send a dns query. The callback will be called when the packet was sent.

The following shorthands are equivalent

mdns.query('brunhilde.local', 'A')
mdns.query([{name:'brunhilde.local', type:'A'}])
  questions: [{name:'brunhilde.local', type:'A'}]

mdns.respond(packet, [cb])

Send a dns response. The callback will be called when the packet was sent.

// reply with a SRV and a A record as an answer
  answers: [{
    name: 'my-service',
    type: 'SRV',
    data: {
      weigth: 0,
      priority: 10,
      target: ''
  }, {
    name: 'brunhilde.local',
    type: 'A',
    ttl: 300,
    data: ''

The following shorthands are equivalent

mdns.respond([{name:'brunhilde.local', type:'A', data:''}])
  answers: [{name:'brunhilde.local', type:'A', data:''}]


Destroy the mdns instance. Closes the udp socket.


To start hacking on this module you can use this example to get started

git clone git://
npm install
node example.js
node cli.js $(hostname).local



multicast-dns open issues Ask a question     (View All Issues)
  • about 3 years Fails to bind
  • about 3 years Not broadcasting on all interfaces
  • over 3 years Any reason for this not to work if Apple bonjour is installed (W7) ?
  • over 4 years Reverse lookups and PTR packages
  • over 4 years Can crash with uncaught exception without a gateway
multicast-dns open pull requests (View All Pulls)
  • Manually bind to all external IPv4 interfaces
  • Catch and emit error on socket.addMembership
  • Add Typescript 2.x typings
  • Multi-interface support.
  • Multi-interface support (with conflict resolved).
  • 'networkInterface' event
multicast-dns questions on Stackoverflow (View All Questions)
  • Multicast DNS problems
  • How to register for a multicast DNS service in a chrome app
  • How to do a multicast DNS query in
  • Get Link-Local Domain Name from IP Address (i.e. Reverse DNS Lookup with Multicast DNS & DNS-SD)
multicast-dns list of languages used
Other projects in JavaScript