chrome.dns Stay organized with collections Save and categorize content based on your preferences.
Description
Use thechrome.dns API for dns resolution.
Permissions
dnsAvailability
To use this API, you must declare the"dns" permission in themanifest.
{"name":"My extension",..."permissions":["dns"],...}Usage
The following code callsresolve() to retrieve the IP address ofexample.com.
service-worker.js:
constresolveDNS=async()=>{letrecord=awaitchrome.dns.resolve('example.com');console.log(record.address);// "192.0.2.172"};resolveDNS();https://example.com/ is invalid.Types
ResolveCallbackResolveInfo
Properties
- address
string optional
A string representing the IP address literal. Supplied only if resultCode indicates success.
- resultCode
number
The result code. Zero indicates success.
Methods
resolve()
chrome.dns.resolve(
hostname: string,
): Promise<ResolveCallbackResolveInfo>
Resolves the given hostname or IP address literal.
Parameters
- hostname
string
The hostname to resolve.
Returns
Promise<ResolveCallbackResolveInfo>
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-11 UTC.