DNS

resolver.getServers()

Reads configured DNS servers of an instance. A configured address does not establish that the server answers or is trustworthy. Tested on Node.js 22.16.0. Example output (one line per entry): ["1 true"].

Formal Syntax & Structure

nodejs syntaxnodejs
resolver.getServers()

Return Value

string[]

Configured resolver endpoints.

Working Example

Example Snippetnodejs
import { Resolver } from 'node:dns';const r = new Resolver();r.setServers(['127.0.0.1:53535']);const servers = r.getServers();console.log(servers.length, servers[0].startsWith('127.0.0.1'));
Node.js Reference