Node.js – dns.resolveSoa() Method

Node.jsServer Side ProgrammingProgramming

The dns.resolveSoa() method uses the DNS protocol to resolve the start of authority records for the hostname. The address argument passed to the callback function will be an object that will contain the following properties −

  • nsname
  • hostmaster
  • serial
  • refresh
  • entry
  • expire


dns.resolveSoa(hostname, callback)


It accepts the following parameters −

  • hostname – This parameter takes the input for the hostname to be resolved.

  • callback – This function will catch errors, if any.

    • records – Returns the start of authority records for the hostname.


Create a file with the name "resolveSoa.js" and copy the following code snippet. After creating the file, use the command node "resolveSoa.js" to run this code as shown in the example below −

// dns.resolveSoa() Demo Example

// Importing the dns module
const dns = require('dns');

// Passing the argument below
dns.resolveSoa('', (err, records) => console.log('SOA Records: %j', records));


C:\home\node>> node resolveSoa.js
SOA Records: {
Published on 17-Jan-2022 11:26:39