Skip to main content
lookupService - node__dns--promises.d.ts - Node documentation
function lookupService

Usage in Deno

```typescript import { lookupService } from "node:node__dns--promises.d.ts"; ```
lookupService(
address: string,
port: number,
): Promise<{ hostname: string; service: string; }>
Resolves the given `address` and `port` into a host name and service using the operating system's underlying `getnameinfo` implementation. If `address` is not a valid IP address, a `TypeError` will be thrown. The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown. On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) object, where `err.code` is the error code. ```js import dnsPromises from 'node:dns'; dnsPromises.lookupService('127.0.0.1', 22).then((result) => { console.log(result.hostname, result.service); // Prints: localhost ssh }); ```

Parameters

address: string
port: number

Return Type

Promise<{ hostname: string; service: string; }>