docmirror/dev-sidecar · warning
----- ${action}: ${hostname}, dns returned invalid ip
Error message
----- ${action}: ${hostname}, dns returned invalid ip What it means
The custom lookup function created by createLookupFunc asks the configured DNS for the hostname. If the DNS result is non-null, differs from the hostname, but is not a valid IP address (isValidIpAddress fails), the value is treated as garbage: a warning is logged and the lookup falls back to Node's default DNS for that request, so resolution still succeeds.
Source
Thrown at packages/mitmproxy/src/lib/proxy/mitmproxy/dnsLookup.js:109
dns.lookup(hostname, { ipChecker, family }).then((ip) => {
if (ip !== hostname && isValidIpAddress(ip)) {
const addressFamily = getAddressFamily(ip)
if (isDnsIntercept) {
isDnsIntercept.dns = dns
isDnsIntercept.hostname = hostname
isDnsIntercept.ip = ip
if (tester) isDnsIntercept.tester = tester
}
log.info(`----- ${action}: ${hostname}, use ip from dns '${dns.dnsName}': ${ip}(family: ${addressFamily})${target} -----`)
if (res) {
const dnsLabel = dns.dnsName === '预设IP' ? 'PreSet' : safeHeaderValue(dns.dnsName)
res.setHeader('DS-DNS-Lookup', `DNS: ${ip} (IPv${addressFamily}) ${dnsLabel}`)
}
respondLookup(callback, ip, addressFamily, all)
} else {
// 使用默认dns
if (ip != null && ip !== hostname && !isValidIpAddress(ip)) {
log.warn(`----- ${action}: ${hostname}, dns returned invalid ip '${ip}'${target}, fallback to default DNS`)
}
log.info(`----- ${action}: ${hostname}, use default DNS: ${hostname}${target}, options:`, options, ', dns:', dns)
defaultDns.lookup(hostname, options, callback)
}
}).catch((err) => {
log.error(`----- ${action}: ${hostname}, dns lookup error${target}, options:`, options, `, error:`, err)
defaultDns.lookup(hostname, options, callback)
})
}
},
}
View on GitHub (pinned to 7710cd56cc)
Solutions
- Inspect the DNS/ip list for the offending hostname and correct entries to be plain IPv4/IPv6 literals.
- Remove the bad preset ip entry so the request uses default or another DNS backend.
- Reset the DNS config to shipped defaults and re-apply your customizations one at a time to find the invalid value.
- No action strictly required — the code already falls back to default DNS; fix the config to stop losing the speed/availability benefits of custom DNS.
Example fix
// before (preset ips) ["github.com", "140.82.112.3"] // after ["140.82.112.3", "140.82.113.4"]
Defensive patterns
Strategy: validation
Validate before calling
const bad = presetIps.filter(ip => !/^(\d{1,3}(\.\d{1,3}){3}|[0-9a-fA-F:]+)$/.test(ip))
if (bad.length) console.error('remove invalid ips:', bad) Type guard
const isValidIpAddress = (s) => typeof s === 'string' && (/^(\d{1,3}\.){3}\d{1,3}$/.test(s) || s.includes(':')) Prevention
- Keep preset ip lists strictly as IP literals — no hostnames or ip:port strings
- Validate user-edited DNS config after every manual change
- Reset to default DNS config when resolution misbehaves, then re-customize incrementally
When it happens
Trigger: A DNS module (preset ip list, DoH provider, custom dnsMap entry) returns a string that is not an IPv4/IPv6 literal — e.g. a preset list containing a domain name, a truncated/annotated IP, or DoH answer data in unexpected format.
Common situations: Hand-edited pre-set ip files where someone put hostnames or 'ip:port' strings; third-party DoH services returning CNAME-formatted data handled incorrectly; corrupted user config under ~/.dev-sidecar.
Related errors
- 域名 ${rOptions.hostname} 在dns中未配置,但使用了 sni: ${rOptions.server
- FreeEye runtime config is required.
- 无效的代理 IP 地址: ${ip}
- 无效的代理端口号: ${port}
- Unknown type DNS: ${server}, provider: ${provider}
AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31).
Data as JSON: /api/errors/010969f42220ea4a.
Report an issue: GitHub.