{"record":{"id":"ecacefe4cc80ae5a","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"searxng-search-failed-str-e","errorCode":null,"errorMessage":"SearXNG search failed: {str(e)}","messagePattern":"SearXNG search failed: (.+?)","errorType":"exception","errorClass":"SearchRequestError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/utils/research_web.py","lineNumber":370,"sourceCode":"        \"time_range\": \"\",\n        \"engines\": \"duckduckgo,bing,brave\",\n        \"results\": max_results,\n    }\n\n    try:\n        response = requests.get(\n            f\"http://localhost:{port}/search\",\n            params=params,\n            headers=headers,\n            timeout=timeout,\n        )\n        response.raise_for_status()\n\n        json_data = response.json()\n        results = [result[\"url\"] for result in json_data.get(\"results\", [])]\n        return results[:max_results]\n    except Exception as e:\n        raise SearchRequestError(f\"SearXNG search failed: {str(e)}\")\n\n\ndef _search_serper(\n    query: str, max_results: int, api_key: str, timeout: int\n) -> List[str]:\n    \"\"\"\n    Helper function for Serper search.\n\n    Args:\n        query (str): Search query\n        max_results (int): Maximum number of results to return\n        api_key (str): API key for Serper\n        timeout (int): Request timeout in seconds\n\n    Returns:\n        List[str]: List of URLs from search results\n    \"\"\"\n    if not api_key:","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/utils/research_web.py#L352-L388","documentation":"Raised by the SearXNG backend when querying the SearXNG instance fails: connection refused, non-2xx status (raise_for_status), or invalid JSON. Wrapped into SearchRequestError with the original message.","triggerScenarios":"Calling search_on_web with engine='searxng' when the SearXNG instance at the configured port is not running, returns an error status, or responds with non-JSON content.","commonSituations":"SearXNG Docker container not started or crashed; wrong port in config; instance blocking external clients; JSON format disabled on the instance.","solutions":["Verify the SearXNG instance is up (curl its /search endpoint with format=json)","Fix the port/host configuration","Enable JSON output on the SearXNG instance (json format must be allowed)","Retry with backoff for transient instance overload"],"exampleFix":"// before\nconfig.search_engine = \"searxng\"  # instance down -> SearchRequestError\n// after\n# start instance first: docker run -p 8888:8080 searxng/searxng\nconfig.search_engine = \"searxng\"; config.port = 8888","handlingStrategy":"validation","validationCode":"import requests\ndef searxng_up(port):\n    try:\n        r = requests.get(f\"http://localhost:{port}/search\", params={\"q\": \"test\", \"format\": \"json\"}, timeout=5)\n        return r.ok\n    except requests.RequestException:\n        return False\nif config.search_engine == \"searxng\" and not searxng_up(config.port):\n    raise RuntimeError(\"SearXNG instance not reachable\")","typeGuard":null,"tryCatchPattern":"try:\n    results = search_on_web(config)\nexcept SearchRequestError as e:\n    logger.error(\"searxng failed: %s\", e); results = []","preventionTips":["Health-check the SearXNG instance before running graphs","Enable JSON format on the instance","Run SearXNG with a restart policy / supervisor"],"tags":["searxng","network","self-hosted"],"backgroundTag":"service-unavailable","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}