Free WHOIS Node.js Client
freewhois is a Node.js client designed for retrieving WHOIS information by querying the IANA RDAP DNS database. It provides a free and programmatic way to perform domain lookups. The current stable version is 1.3.8. While a specific release cadence isn't detailed, the TLD list is noted as being updated regularly (last on 11/2/2025), suggesting ongoing maintenance. Its key differentiator is leveraging the IANA RDAP database directly, offering a straightforward, free API for WHOIS queries without relying on external, potentially rate-limited, third-party services. It supports both programmatic use in JavaScript/TypeScript projects and includes a command-line interface for quick lookups, making it versatile for both developers and system administrators.
Common errors
-
TypeError: whois is not a function
cause Attempting to call `whois` after importing it incorrectly, e.g., using `import { whois } from 'freewhois';` when it's a default export.fixFor ESM, use `import whois from 'freewhois';`. For CommonJS, use `const whois = require('freewhois');`. -
Error: ENOTFOUND <hostname>
cause The domain name provided is either syntactically invalid, or the DNS lookup for the corresponding RDAP server failed.fixVerify the spelling and format of the domain name. Check your network's DNS resolution, and ensure the domain's TLD is recognized and has an active RDAP service. -
Error: Domain not found for <domain>
cause The provided domain name is valid but does not exist or is not registered.fixThis is expected behavior for unregistered domains. No fix is needed unless you intended to query a registered domain; in that case, double-check the domain's spelling and existence.
Warnings
- gotcha The package relies on a list of TLDs sourced from iana.org. This list is updated manually. If you are experiencing issues with new TLDs or incorrect lookups, your local TLD list might be outdated.
- gotcha WHOIS lookups involve external network requests to various RDAP servers. Network connectivity issues, DNS resolution problems, or temporary unavailability of specific RDAP servers can cause lookups to fail.
- gotcha While `freewhois` uses IANA RDAP for 'free' lookups, aggressive querying (e.g., thousands of requests per second) can still lead to temporary IP blocking or rate limiting by the individual TLD's RDAP servers.
Install
-
npm install freewhois -
yarn add freewhois -
pnpm add freewhois
Imports
- whois
import whois from 'freewhois';
const whois = require('freewhois'); - whois
import { whois } from 'freewhois';import whois from 'freewhois';
- freewhois CLI
npm i freewhois -g freewhois "google.com"
Quickstart
const whois = require('freewhois');
async function performWhoisLookup(domain) {
try {
console.log(`
Looking up WHOIS for: ${domain}`);
const data = await whois(domain);
console.log(`WHOIS data for ${domain}:`);
console.log(JSON.stringify(data, null, 2));
} catch (error) {
console.error(`Error looking up WHOIS for ${domain}:`, error.message);
if (error.response && error.response.status) {
console.error(`HTTP Status: ${error.response.status}`);
}
}
}
// Example usage for a well-known domain
performWhoisLookup('google.com');
// Example for a common TLD
performWhoisLookup('example.com');
// Example for a domain that likely does not exist, to demonstrate error handling
performWhoisLookup('nonexistent-domain-1234567890.xyz');