{"record":{"id":"d201e23930fad6b4","repo":"assafelovic/gpt-researcher","slug":"error-querying-searxng-str-e","errorCode":null,"errorMessage":"Error querying SearxNG: {str(e)}","messagePattern":"Error querying SearxNG: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"gpt_researcher/retrievers/searx/searx.py","lineNumber":86,"sourceCode":"        search_url = urljoin(self.base_url, \"search\")\n        # TODO: Add support for query domains\n        params = {\n            # The search query.\n            'q': self.query,\n            # Output format of results. Format needs to be activated in searxng config.\n            'format': 'json'\n        }\n\n        try:\n            response = requests.get(\n                search_url,\n                params=params,\n                headers={'Accept': 'application/json'}\n            )\n            response.raise_for_status()\n            results = response.json()\n        except requests.exceptions.RequestException as e:\n            raise Exception(f\"Error querying SearxNG: {str(e)}\")\n        except json.JSONDecodeError:\n            raise Exception(\"Error parsing SearxNG response\")\n\n        if not isinstance(results, dict):\n            return []\n\n        search_response = []\n        raw_results = results.get('results', [])\n        if not isinstance(raw_results, list):\n            return []\n\n        for result in raw_results:\n            if not isinstance(result, dict):\n                continue\n            href = result.get('url') or result.get('href') or ''\n            if not href:\n                continue\n            body = result.get('content') or result.get('snippet') or ''","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/assafelovic/gpt-researcher/blob/6f998577d547b1e54ec662dac63583aa11e3b84b/gpt_researcher/retrievers/searx/searx.py#L68-L104","documentation":"Exception raised by SearxNG search() when the HTTP request to the instance fails at the transport/HTTP layer — raise_for_status() throws, or a connection/timeout error occurs — wrapped into Exception(f\"Error querying SearxNG: {e}\"). The embedded text carries the underlying requests error (DNS failure, 403, timeout, etc.).","triggerScenarios":"search() issues requests.get(url, params, headers); any requests.exceptions.RequestException (ConnectionError, Timeout, HTTPError from a 4xx/5xx status) triggers it.","commonSituations":"SearX_URL pointing to a dead/blocked instance, instance returning 403 (bot detection or JSON format disabled), timeouts on slow public instances, or network/DNS issues from the host.","solutions":["Read the embedded requests error: 403 usually means JSON output disabled — enable it in the instance's settings.yml.","Test the instance manually: curl 'SEARX_URL/search?q=test&format=json'.","Point SEARX_URL at a healthy instance (or self-host one with JSON enabled) and retry.","Add retry/timeout handling for flaky public instances."],"exampleFix":"# before\nresults = retriever.search(max_results=10)\n\n# after\ntry:\n    results = retriever.search(max_results=10)\nexcept Exception as e:\n    logger.warning(f\"SearxNG unavailable: {e}\")\n    results = []","handlingStrategy":"fallback","validationCode":"import requests, os\nurl = os.environ[\"SEARX_URL\"].rstrip('/') + '/'\ndef searx_healthy():\n    try:\n        r = requests.get(url + 'search', params={'q': 'test', 'format': 'json'}, timeout=5)\n        return r.status_code == 200\n    except requests.RequestException:\n        return False","typeGuard":"null","tryCatchPattern":"try:\n    results = retriever.search(max_results=10)\nexcept Exception as e:\n    if \"Error querying SearxNG\" in str(e):\n        results = backup_retriever.search(max_results=10)\n    else:\n        raise","preventionTips":["Health-check the SearxNG instance at startup with a tiny query.","Use a reliable/self-hosted instance with JSON enabled.","Add timeouts and a fallback retriever for flaky public instances."],"tags":["searxng","http-error","network","retriever"],"backgroundTag":"http-request-failed","analyzedSha":"6f998577d547b1e54ec662dac63583aa11e3b84b","analyzedAt":"2026-08-28T17:50:07.383Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}