{"record":{"id":"f594861596e25796","repo":"langgenius/dify","slug":"elasticsearch-host-is-required-for-self-hosted-ela","errorCode":null,"errorMessage":"ELASTICSEARCH_HOST is required for self-hosted Elasticsearch","messagePattern":"ELASTICSEARCH_HOST is required for self-hosted Elasticsearch","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"api/configs/middleware/vdb/elasticsearch_config.py","lineNumber":68,"sourceCode":"    )\n    ELASTICSEARCH_RETRY_ON_TIMEOUT: bool = Field(\n        description=\"Whether to retry requests on timeout (default is True)\", default=True\n    )\n    ELASTICSEARCH_MAX_RETRIES: int = Field(\n        description=\"Maximum number of retry attempts (default is 10000)\", default=10000\n    )\n\n    @model_validator(mode=\"after\")\n    def validate_elasticsearch_config(self):\n        \"\"\"Validate Elasticsearch configuration based on deployment type.\"\"\"\n        if self.ELASTICSEARCH_USE_CLOUD:\n            if not self.ELASTICSEARCH_CLOUD_URL:\n                raise ValueError(\"ELASTICSEARCH_CLOUD_URL is required when using Elastic Cloud\")\n            if not self.ELASTICSEARCH_API_KEY:\n                raise ValueError(\"ELASTICSEARCH_API_KEY is required when using Elastic Cloud\")\n        else:\n            if not self.ELASTICSEARCH_HOST:\n                raise ValueError(\"ELASTICSEARCH_HOST is required for self-hosted Elasticsearch\")\n            if not self.ELASTICSEARCH_USERNAME:\n                raise ValueError(\"ELASTICSEARCH_USERNAME is required for self-hosted Elasticsearch\")\n            if not self.ELASTICSEARCH_PASSWORD:\n                raise ValueError(\"ELASTICSEARCH_PASSWORD is required for self-hosted Elasticsearch\")\n\n        return self\n","sourceCodeStart":50,"sourceCodeEnd":75,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/configs/middleware/vdb/elasticsearch_config.py#L50-L75","documentation":"Raised by validate_elasticsearch_config in the self-hosted branch (ELASTICSEARCH_USE_CLOUD false) when ELASTICSEARCH_HOST is empty. The default is '127.0.0.1', so this only fires if an operator explicitly blanks the host.","triggerScenarios":"Setting ELASTICSEARCH_HOST='' (empty string) with ELASTICSEARCH_USE_CLOUD unset/false.","commonSituations":"Unsetting the host expecting the driver to skip ES, or a templated env that renders an empty value.","solutions":["Set ELASTICSEARCH_HOST to the ES hostname/IP (e.g. 'elasticsearch' or '10.0.0.5').","If ES is not used, choose a different VECTOR_STORE so the ES client is never instantiated.","Remove the empty override so the '127.0.0.1' default applies."],"exampleFix":"// before\nELASTICSEARCH_HOST=\n// after\nELASTICSEARCH_HOST=elasticsearch","handlingStrategy":"validation","validationCode":"def es_host_present(use_cloud: bool, host: str | None) -> bool:\n    return use_cloud or bool(host)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not blank ELASTICSEARCH_HOST; let the default apply if unused.","Choose a non-elasticsearch VECTOR_STORE when ES is not used.","Lint env files for empty overrides of defaulted settings."],"tags":["config","pydantic","elasticsearch","vdb","required-field"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}