{"record":{"id":"a0b116c5695aa32c","repo":"assafelovic/gpt-researcher","slug":"searxng-url-not-found-please-set-the-searx-url-en","errorCode":null,"errorMessage":"SearxNG URL not found. Please set the SEARX_URL environment variable. You can find public instances at https://searx.space/","messagePattern":"SearxNG URL not found\\. Please set the SEARX_URL environment variable\\. You can find public instances at https://searx\\.space/","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"gpt_researcher/retrievers/searx/searx.py","lineNumber":55,"sourceCode":"            query: Search query string\n        \"\"\"\n        self.query = query\n        self.query_domains = query_domains or None\n        self.base_url = self.get_searxng_url()\n\n    def get_searxng_url(self) -> str:\n        \"\"\"\n        Gets the SearxNG instance URL from environment variables\n        Returns:\n            str: Base URL of SearxNG instance\n        \"\"\"\n        try:\n            base_url = os.environ[\"SEARX_URL\"]\n            if not base_url.endswith('/'):\n                base_url += '/'\n            return base_url\n        except KeyError:\n            raise Exception(\n                \"SearxNG URL not found. Please set the SEARX_URL environment variable. \"\n                \"You can find public instances at https://searx.space/\"\n            )\n\n    def search(self, max_results: int = 10) -> List[Dict[str, str]]:\n        \"\"\"\n        Searches the query using SearxNG API\n        Args:\n            max_results: Maximum number of results to return\n        Returns:\n            List of dictionaries containing search results\n        \"\"\"\n        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.","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/assafelovic/gpt-researcher/blob/6f998577d547b1e54ec662dac63583aa11e3b84b/gpt_researcher/retrievers/searx/searx.py#L37-L73","documentation":"Exception raised by the SearxNG retriever when the SEARX_URL environment variable is unset (KeyError caught and re-raised). SearxNG is self-hosted/community-hosted metasearch, so the instance URL must be configured explicitly.","triggerScenarios":"Constructing the SearxNG retriever; __init__ calls get_searxng_url(), which raises when SEARX_URL is missing. A trailing slash is appended automatically when present.","commonSituations":"No SEARX_URL set for a self-hosted instance, .env not loaded, URL pointing to an instance with JSON output disabled, or var name typoed.","solutions":["export SEARX_URL=https://your-searx-instance (public instances at https://searx.space/).","If self-hosting, enable JSON format in settings.yml (search.formats: [html, json]).","Add SEARX_URL to .env and verify it loads before retriever creation."],"exampleFix":"# before\nretriever = SearxNG(query=\"...\")\n\n# after\nexport SEARX_URL=http://localhost:8888\n# then\nretriever = SearxNG(query=\"...\")","handlingStrategy":"validation","validationCode":"import os\nfrom urllib.parse import urlparse\nurl = os.environ.get(\"SEARX_URL\")\nif not url or not urlparse(url).scheme:\n    raise SystemExit(\"Set SEARX_URL to a SearxNG instance (https://searx.space/)\")","typeGuard":"null","tryCatchPattern":"try:\n    retriever = SearxNG(query)\nexcept Exception as e:\n    if \"SEARX_URL\" in str(e):\n        sys.exit(str(e))\n    raise","preventionTips":["Set SEARX_URL in .env; prefer a self-hosted instance you control.","Confirm the instance allows format=json before relying on it.","Preflight the URL at startup."],"tags":["searxng","missing-env-var","url-configuration","retriever"],"backgroundTag":"missing-env-var","analyzedSha":"6f998577d547b1e54ec662dac63583aa11e3b84b","analyzedAt":"2026-08-28T17:50:07.383Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}