Tencent/WeKnora · error
failed to execute request: %w
Error message
failed to execute request: %w
What it means
The HTTP GET to the SearXNG instance failed at the transport layer: DNS failure, connection refused, TLS handshake error, or context cancellation/timeout. The provider wraps the underlying *url.Error so the root cause (e.g. 'connection refused') is preserved.
Source
Thrown at internal/infrastructure/web_search/searxng.go:126
// Use "all" (SearXNG's documented value for "no language filter") instead
// of "auto", which is a UI-side default and not a valid /search parameter.
// safesearch is intentionally not set here so the value configured in the
// instance's settings.yml is honored.
q.Set("language", "all")
reqURL := p.baseURL + "/search?" + q.Encode()
logger.Infof(ctx, "[WebSearch][SearXNG] query=%q maxResults=%d url=%s", query, maxResults, p.baseURL)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", "WeKnora/1.0")
resp, err := p.client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to execute request: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(io.LimitReader(resp.Body, 1024))
return nil, fmt.Errorf("searxng returned status %d: %s", resp.StatusCode, string(body))
}
var data searxngResponse
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
p.lastUnresponsive = nil
return nil, fmt.Errorf("failed to decode SearXNG response (ensure JSON format is enabled in settings.yml): %w", err)
}
p.lastUnresponsive = data.UnresponsiveEngines
results := make([]*types.WebSearchResult, 0, maxResults)
for _, r := range data.Results {
if len(results) >= maxResults {View on GitHub (pinned to 988cbb0330)
Solutions
- Unwrap the error (errors.Unwrap or %v of the wrapped url.Error) to see the exact cause (refused vs timeout vs DNS)
- Verify SearXNG is reachable: curl '<baseURL>/search?q=test&format=json' from the backend host
- Fix baseURL host/port and any proxy configuration; confirm container networking (docker network) if self-hosted
- Increase the HTTP client timeout or shorten the query workload if it is a timeout; add retry with backoff for transient network faults
Example fix
// before
results, err := provider.Search(ctx, q, 5, false)
if err != nil { return err }
// after
results, err := provider.Search(ctx, q, 5, false)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
return retryWithBackoff(ctx, q) // transient timeout
}
return fmt.Errorf("web search unavailable: %w", err)
} Defensive patterns
Strategy: retry
Validate before calling
// preflight reachability check
resp, err := http.Head(baseURL)
if err != nil {
return fmt.Errorf("searxng unreachable: %w", err)
}
resp.Body.Close() Try / catch
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
// retry with backoff
} else if strings.Contains(err.Error(), "connection refused") {
// service down: alert / fallback to another provider
} Prevention
- Health-check the SearXNG endpoint at startup
- Set sensible HTTP client timeouts and retry transient failures with backoff
- Confirm container networking/egress rules before deploying
- Monitor the provider and fail over to another web-search provider on repeated network errors
When it happens
Trigger: SearXNG host unreachable or down; wrong port in baseURL; network egress blocked from the backend; ctx deadline exceeded while the request was in flight.
Common situations: SearXNG container not running or on a different Docker network; firewall/egress rules blocking outbound calls; DNS name typo; slow SearXNG instance exceeding the HTTP client timeout.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/fa512bd101a5b349.
Report an issue: GitHub.