Skip to content

Function: isLoopbackHost()

isLoopbackHost(input): boolean

Whether input’s host is a loopback address - localhost, an IPv4 127.0.0.0/8 address, or IPv6 ::1 - i.e. a service running on this machine (e.g. a local registry). Accepts anything urlBuilder coerces (a URL string, URL, or { url }); returns false when the input has no resolvable host.

UrlLike

boolean

isLoopbackHost("http://localhost:4873"); // true
isLoopbackHost("http://127.0.0.1"); // true
isLoopbackHost("https://registry.npmjs.org"); // false