FlowiseAI/Flowise · error · Error
DNS resolution failed for ${hostname}
Error message
DNS resolution failed for ${hostname} What it means
Thrown by resolveAndValidate() when dns.lookup() returns an empty records array for the hostname. Normally dns.lookup throws ENOTFOUND for unresolvable hostnames, so reaching this branch (records.length === 0) is itself unusual — it indicates the OS resolver returned no A/AAAA records without throwing. The error surfaces a hostname that cannot be mapped to any IP for deny-list validation.
Source
Thrown at packages/components/src/httpSecurity.ts:318
// Strip IPv6 brackets if present
if (hostname.startsWith('[') && hostname.endsWith(']')) {
hostname = hostname.slice(1, -1)
}
const protocol: 'http' | 'https' = u.protocol === 'https:' ? 'https' : 'http'
if (ipaddr.isValid(hostname)) {
isDeniedIP(hostname, denyList)
return {
hostname,
ip: hostname,
family: hostname.includes(':') ? 6 : 4,
protocol
}
}
const records = await dns.lookup(hostname, { all: true })
if (records.length === 0) {
throw new Error(`DNS resolution failed for ${hostname}`)
}
for (const r of records) {
isDeniedIP(r.address, denyList)
}
const chosen = records.find((r) => r.family === 4) ?? records[0]
return {
hostname,
ip: chosen.address,
family: chosen.family as 4 | 6,
protocol
}
}
function createPinnedAgent(target: ResolvedTarget, options?: { ca?: string | string[] | Buffer }): http.Agent | https.Agent {
const Agent = target.protocol === 'https' ? https.Agent : http.AgentView on GitHub (pinned to abe4a8601a)
Solutions
- Verify the hostname resolves from the runtime environment: run dig or nslookup in the same container/host.
- Retry the request after confirming DNS is healthy (transient failures do occur).
- If the hostname is internal, ensure the runtime can reach the corporate/internal DNS resolver.
- Fall back to a cached IP if the hostname is known-stable and the failure is transient.
Example fix
// before
const resp = await secureFetch('https://flakey-host.example.com/path')
// after
// pre-check resolution and retry once on failure
async function safeFetch(url) {
try { return await secureFetch(url) }
catch (e) {
if (String(e).includes('DNS resolution failed')) {
await new Promise(r => setTimeout(r, 500))
return secureFetch(url)
}
throw e
}
} Defensive patterns
Strategy: retry
Validate before calling
// Pre-resolve to fail fast with a clear message
import dns from 'dns/promises'
async function ensureResolvable(hostname: string) {
const records = await dns.lookup(hostname, { all: true })
if (!records.length) throw new Error(`No DNS records for ${hostname}`)
return records
}
await ensureResolvable(new URL(url).hostname)
await secureFetch(url) Try / catch
async function fetchWithDnsRetry(url: string, init?: any, retries = 2) {
for (let attempt = 0; attempt <= retries; attempt++) {
try {
return await secureFetch(url, init)
} catch (e) {
if (String(e).includes('DNS resolution failed') && attempt < retries) {
await new Promise((r) => setTimeout(r, 500 * (attempt + 1)))
continue
}
throw e
}
}
throw new Error('unreachable')
} Prevention
- Verify DNS works from the runtime container (dig/nslookup).
- Use a stable internal DNS resolver and configure retries at the resolver level.
- Cache successful resolutions for short TTLs to ride through transient failures.
When it happens
Trigger: A URL whose hostname passes the ipaddr.isValid() check (i.e. it is a hostname, not a literal IP) but for which dns.lookup returns zero records. Possible with exotic resolver configurations, transient DNS issues, or hostnames that exist in /etc/hosts with no resolved address. The check at line 317 fires after the await.
Common situations: Misconfigured DNS or a hostname typo. A hostname that resolves intermittently. A private DNS zone unreachable from the runtime. /etc/hosts entry with no address. Network partition during resolution. A hostname that only has records of a family not queried.
Understand the failure class
- DNS resolution errors: ENOTFOUND and getaddrinfo failures — how hostname lookups fail and how to debug them.
Related errors
- Access to this host is denied by policy.
- Failed to post ${url}: ${error}
- Failed to make GET request: ${error instanceof Error ? error
- Failed to make POST request: ${error instanceof Error ? erro
- Failed to make PUT request: ${error instanceof Error ? error
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/f787443166c3d6b1.
Report an issue: GitHub.