docmirror/dev-sidecar · error
Unknown type DNS: ${server}, provider: ${provider}
Error message
Unknown type DNS: ${server}, provider: ${provider} What it means
initDNS() parses each configured DNS provider to classify it as https/tls/tcp/udp. If a server string contains '://' but does not start with a recognized scheme (udp://, https://, tls://, dot://, tcp://), the library cannot infer the transport and throws immediately. This is a fail-fast guard against misconfigured DNS providers that would otherwise silently fail at query time.
Source
Thrown at packages/mitmproxy/src/lib/dns/index.js:37
let server = conf.server || conf.host
if (server != null) {
server = server.replace(/\s+/, '')
}
if (!server) {
continue
}
// 获取DNS类型
let type = conf.type
if (type == null) {
if (server.startsWith('https://') || server.startsWith('http://')) {
type = 'https'
} else if (server.startsWith('tls://') || server.startsWith('dot://')) {
type = 'tls'
} else if (server.startsWith('tcp://')) {
type = 'tcp'
} else if (server.includes('://') && !server.startsWith('udp://')) {
throw new Error(`Unknown type DNS: ${server}, provider: ${provider}`)
} else {
type = 'udp'
}
} else {
type = type.replace(/\s+/, '').toLowerCase()
}
// 获取DNS的Family值
const family = conf.family
// 创建DNS对象
if (type === 'https' || type === 'doh' || type === 'dns-over-https') {
if (!server.includes('/')) {
server = `https://${server}/dns-query`
}
// 基于 https
dnsMap[provider] = new DNSOverHTTPS(provider, conf.cacheSize, preSetIpList, server, family, conf.sni || conf.servername)View on GitHub (pinned to 7710cd56cc)
Solutions
- Open ~/.dev-sidecar/config.json (or the merged running config) and find the dns.providers entry referenced in the message
- Change the server scheme to a supported one: https://, tls:// (or dot://), tcp://, or udp:// (or a bare IP meaning udp)
- For DoH/DoT providers only available over QUIC, pick their https/tls endpoint instead (e.g. use https://cloudflare-dns.com/dns-query)
- If a custom type is intended, set the provider's explicit 'type' field to one of: https, tls, tcp, udp (whitespace is stripped and lowercased)
Example fix
// before
dns: { providers: { custom: { server: 'quic://dns.adguard.com' } } }
// after
dns: { providers: { custom: { server: 'https://dns.adguard.com/dns-query', type: 'https' } } } Defensive patterns
Strategy: validation
Validate before calling
const SCHEMES = ['udp://', 'https://', 'tls://', 'dot://', 'tcp://']
function isValidDnsServer(p) {
if (!p || !p.server) return false
const s = String(p.server)
if (p.type) return ['https', 'tls', 'tcp', 'udp'].includes(String(p.type).trim().toLowerCase())
if (!s.includes('://')) return true
return SCHEMES.some(pre => s.startsWith(pre))
}
// before startup: Object.entries(config.dns.providers).every(([k, p]) => isValidDnsServer(p)) Type guard
function hasKnownScheme(server) {
return typeof server === 'string' && (
!server.includes('://') ||
/^(udp|https|tls|dot|tcp):\/\//.test(server)
)
} Try / catch
try {
await DevSidecar.api.startup()
} catch (e) {
if (String(e.message).startsWith('Unknown type DNS:')) {
console.error('Bad dns provider config:', e.message)
delete config.dns.providers.offending
await DevSidecar.api.startup()
} else throw e
} Prevention
- Only use schemes udp://, https://, tls:// (dot://), tcp:// or bare IPs in dns.providers entries
- Set an explicit type field when unsure of scheme inference
- Validate ~/.dev-sidecar/config.json diffs after hand-editing
- Test config changes with a config dry-run/merge before restart
When it happens
Trigger: Calling initDNS/startup with config.dns.providers containing an entry whose server value has an unrecognized scheme, e.g. 'quic://dns.example.com', 'dns://1.1.1.1', or a typo like 'htps://dns.google'. Also thrown when a provider's 'type' field is absent and the server string cannot be classified.
Common situations: Users copy DNS provider entries from other tools (e.g. dnscrypt-proxy with 'sdns://' stamps or 'quic://' servers) into dev-sidecar config; typos in scheme names; hand-edited ~/.dev-sidecar/config.json overrides.
Related errors
- 域名 ${rOptions.hostname} 在dns中未配置,但使用了 sni: ${rOptions.server
- At least host, servername and name must be set.
- 下载远程配置成功,但内容为空:
- newConfig 为空,不做任何操作
- 插件【${key}】不可用,已注册为禁用状态
AI-assisted analysis of docmirror/dev-sidecar@7710cd56cc (2026-08-31).
Data as JSON: /api/errors/4a257f8b73100d1c.
Report an issue: GitHub.