{"record":{"id":"2ce79689466d2cf5","repo":"temporalio/temporal","slug":"unable-to-create-elasticsearch-client-url-v-u","errorCode":null,"errorMessage":"unable to create Elasticsearch client (URL = %v, username = %q): %w","messagePattern":"unable to create Elasticsearch client \\(URL = (.+?), username = %q\\): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"temporal/fx.go","lineNumber":282,"sourceCode":"\tif persistenceConfig.VisibilityConfigExist() &&\n\t\tpersistenceConfig.DataStores[persistenceConfig.VisibilityStore].Elasticsearch != nil {\n\t\tesConfig = persistenceConfig.DataStores[persistenceConfig.VisibilityStore].Elasticsearch\n\t\tesConfig.SetHttpClient(so.elasticsearchHttpClient)\n\t}\n\n\tif esConfig != nil {\n\t\tesHttpClient := so.elasticsearchHttpClient\n\t\tif esHttpClient == nil {\n\t\t\tvar err error\n\t\t\tesHttpClient, err = esclient.NewAwsHttpClient(esConfig.AWSRequestSigning)\n\t\t\tif err != nil {\n\t\t\t\treturn serverOptionsProvider{}, fmt.Errorf(\"unable to create AWS HTTP client for Elasticsearch: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\tesClient, err = esclient.NewClient(esConfig, esHttpClient, logger)\n\t\tif err != nil {\n\t\t\treturn serverOptionsProvider{}, fmt.Errorf(\"unable to create Elasticsearch client (URL = %v, username = %q): %w\",\n\t\t\t\tesConfig.URL.Redacted(), esConfig.Username, err)\n\t\t}\n\t}\n\n\t// check that when static hosts are defined, they are defined for all required hosts\n\tif len(so.hostsByService) > 0 {\n\t\tfor _, service := range DefaultServices {\n\t\t\thosts := so.hostsByService[primitives.ServiceName(service)]\n\t\t\tif len(hosts.All) == 0 {\n\t\t\t\treturn serverOptionsProvider{}, fmt.Errorf(\"%w: %v\", missingServiceInStaticHosts, service)\n\t\t\t}\n\t\t}\n\t}\n\n\tif so.config.Global.Authorization.RemoteClusterAuth.Require && so.tokenProvider == nil {\n\t\treturn serverOptionsProvider{}, errors.New(\"global.authorization.remoteClusterAuth.require is true but no TokenProvider is configured: use WithTokenProvider\")\n\t}\n\t// TokenCredentials require TLS (RFC 9700); without a remote-cluster TLS source the first","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/temporal/fx.go#L264-L300","documentation":"Wraps a failure from esclient.NewClient while constructing the Elasticsearch client used by Temporal's visibility store during server bootstrap. The wrapper includes the redacted ES URL and username to help identify the misconfigured datastore. Temporal cannot start visibility persistence until a valid ES client is built, so this aborts startup.","triggerScenarios":"Calling temporal.NewServerFx (or NewServer) with a persistence datastore whose Elasticsearch section is set; esclient.NewClient fails, e.g. malformed URL, invalid config fields, or an unusable injected HTTP client.","commonSituations":"Typo or invalid scheme in the elasticsearch.url config value; missing credentials that the ES client constructor rejects; bad AWSRequestSigning settings; custom elasticsearchHttpClient injection erroring during construction.","solutions":["Fix the elasticsearch.url in the persistence datastore config (must be a valid, parseable URL)","Verify elasticsearch username/password and AWSRequestSigning settings are consistent","Check the wrapped root error (%w) for the underlying cause from the ES client library","Test the ES endpoint is reachable with curl before starting Temporal"],"exampleFix":"// before (config)\ndatastores:\n  es-visibility:\n    elasticsearch:\n      url: \"elasticsearchover:9200\"   # invalid URL\n// after\ndatastores:\n  es-visibility:\n    elasticsearch:\n      url: \"http://elasticsearch:9200\"\n      username: \"admin\"\n      password: \"secret\"","handlingStrategy":"validation","validationCode":"cfg := persistenceConfig.DataStores[store].Elasticsearch\nif cfg == nil { return nil }\nif _, err := url.Parse(string(cfg.URL)); err != nil {\n    return fmt.Errorf(\"invalid elasticsearch url: %w\", err)\n}\nif cfg.Username == \"\" && !cfg.AWSRequestSigning.IsSet() {\n    return errors.New(\"elasticsearch credentials or AWS signing required\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate elasticsearch.url parses as a URL before starting the server","Smoke-test the ES endpoint with curl from the server host","Keep credentials and AWSRequestSigning mutually consistent","Test datastore configs in CI with a startup dry-run"],"tags":["elasticsearch","startup","config","persistence"],"backgroundTag":"elasticsearch-client-init-failed","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}