Tencent/WeKnora · error

DNS resolution failed for %s: %w

Error message

DNS resolution failed for %s: %w

What it means

Fired in pinnedDialContext when f.resolveIPs fails to resolve the target host — DNS lookup returned an error (resolver outage, unknown host, context timeout). The fetch is aborted to enforce IP pinning before connecting.

Source

Thrown at internal/infrastructure/web_fetch/fetcher.go:235

	finalURL := rawURL
	if resp.Request != nil && resp.Request.URL != nil {
		finalURL = resp.Request.URL.String()
	}
	return &httpFetchResult{body: body, finalURL: finalURL}, nil
}

func (f *Fetcher) pinnedDialContext() func(context.Context, string, string) (net.Conn, error) {
	return func(ctx context.Context, network, address string) (net.Conn, error) {
		host, port, err := net.SplitHostPort(address)
		if err != nil {
			return nil, fmt.Errorf("invalid address %s: %w", address, err)
		}
		if utils.IsSystemProxy(address) || utils.IsSSRFWhitelisted(host) {
			return (&net.Dialer{Timeout: 30 * time.Second, KeepAlive: 30 * time.Second}).DialContext(ctx, network, address)
		}
		ips, err := f.resolveIPs(ctx, host)
		if err != nil {
			return nil, fmt.Errorf("DNS resolution failed for %s: %w", host, err)
		}
		if len(ips) == 0 {
			return nil, fmt.Errorf("DNS resolution failed: no addresses for %s", host)
		}
		for _, ip := range ips {
			if !utils.IsPublicIP(ip) {
				return nil, fmt.Errorf("connection blocked: %s resolves to restricted IP %s", host, ip)
			}
		}
		pinnedAddress := net.JoinHostPort(ips[0].String(), port)
		if f.dialContext != nil {
			return f.dialContext(ctx, network, pinnedAddress)
		}
		return (&net.Dialer{Timeout: 30 * time.Second, KeepAlive: 30 * time.Second}).DialContext(ctx, network, pinnedAddress)
	}
}

func (f *Fetcher) fetchWithBrowser(ctx context.Context, rawURL string) (string, error) {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify the hostname exists and DNS is functioning
  2. Check resolver configuration and network access from the server
  3. If the context timed out, increase the fetch timeout
  4. Retry the fetch; DNS failures are often transient
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/infrastructure/web_fetch/fetcher.go:235 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/b23207d963e9ffba. Report an issue: GitHub.