Skip to main content


Deno standard library
Go to Latest
function setServers
import { setServers } from "";

Sets the IP address and port of servers to be used when performing DNS resolution. The servers argument is an array of RFC 5952 formatted addresses. If the port is the IANA default DNS port (53) it can be omitted.


An error will be thrown if an invalid address is provided.

The dns.setServers() method must not be called while a DNS query is in progress.

The setServers method affects only resolve,dns.resolve*() and reverse (and specifically not lookup).

This method works much like resolve.conf. That is, if attempting to resolve with the first server provided results in a NOTFOUND error, the resolve() method will not attempt to resolve with subsequent servers provided. Fallback DNS servers will only be used if the earlier ones time out or result in some other error.


servers: ReadonlyArray<string>

array of RFC 5952 formatted addresses