--- title: "Key必须使用一致的协议http或https - 如何解决此Elasticsearch异常" date: 2026-02-13 lastmod: 2026-02-13 description: "当Elasticsearch配置中HTTP和HTTPS协议使用不匹配时出现的错误。要求集群中所有节点使用一致的协议(HTTP或HTTPS)。" tags: ["Elasticsearch", "异常处理", "HTTP协议", "HTTPS协议", "配置错误", "SSL证书"] summary: " 版本: 7.5-8.9 简而言之,当 Elasticsearch 配置中 HTTP 和 HTTPS 协议的使用不匹配时,就会出现此错误。Elasticsearch 要求集群中所有节点统一使用 HTTP 或 HTTPS 协议。要解决此问题,请确保 Elasticsearch 集群中的所有节点使用相同的协议。如果您使用的是 HTTPS,请确保所有节点都具有正确的 SSL 证书。此外,请检查您的 elasticsearch.yml 配置文件中是否存在协议不一致的情况。 日志上下文 # 日志 “[” + key + “] must use a consistent scheme: http or https” 的类名是 HttpExporter.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景的人参考: httpsHostFound = true; } // fail if we find them configuring the scheme/protocol in different ways if (httpHostFound && httpsHostFound) { throw new SettingsException("[" + key + "] must use a consistent scheme: http or https"); } } } @Override " --- > **版本:** 7.5-8.9 简而言之,当 Elasticsearch 配置中 HTTP 和 HTTPS 协议的使用不匹配时,就会出现此错误。Elasticsearch 要求集群中所有节点统一使用 HTTP 或 HTTPS 协议。要解决此问题,请确保 Elasticsearch 集群中的所有节点使用相同的协议。如果您使用的是 HTTPS,请确保所有节点都具有正确的 SSL 证书。此外,请检查您的 elasticsearch.yml 配置文件中是否存在协议不一致的情况。 日志上下文 ----------- 日志 "[" + key + "] must use a consistent scheme: http or https" 的类名是 [HttpExporter.java.](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入背景的人参考: ```java httpsHostFound = true; } // fail if we find them configuring the scheme/protocol in different ways if (httpHostFound && httpsHostFound) { throw new SettingsException("[" + key + "] must use a consistent scheme: http or https"); } } } @Override ```