SonarQube is throwing Bad request

I am running SonarQube on my app server and I configured Java and also set it in Environment variable but after running StartSonar.bat getting below error

2023.11.29 10:40:25 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory C:\SonarQube\sonarqube-9.6.1.59531\temp
2023.11.29 10:40:25 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:50714]
2023.11.29 10:40:25 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [C:\SonarQube\sonarqube-9.6.1.59531\elasticsearch]: C:\Program Files\Java\jdk-11\bin\java -XX:+UseG1GC -Djava.io.tmpdir=C:\SonarQube\sonarqube-9.6.1.59531\temp -XX:ErrorFile=../logs/es_hs_err_pid%p.log -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djna.tmpdir=C:\SonarQube\sonarqube-9.6.1.59531\temp -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j2.formatMsgNoLookups=true -Djava.locale.providers=COMPAT -Dcom.redhat.fips=false -Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=C:\SonarQube\sonarqube-9.6.1.59531\elasticsearch -Des.path.conf=C:\SonarQube\sonarqube-9.6.1.59531\temp\conf\es -cp lib/* org.elasticsearch.bootstrap.Elasticsearch
2023.11.29 10:40:25 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2023.11.29 10:40:27 ERROR app[][o.s.a.p.EsManagedProcess] Failed to check status
org.elasticsearch.ElasticsearchException: java.util.concurrent.ExecutionException: org.elasticsearch.client.ResponseException: method [GET], host [http://127.0.0.1:9001], URI [/], status line [HTTP/1.1 400 Bad Request]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>

    at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2695)
    at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:2171)
    at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:2137)
    at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:2105)
    at org.elasticsearch.client.ClusterClient.health(ClusterClient.java:151)
    at org.sonar.application.es.EsConnectorImpl.getClusterHealthStatus(EsConnectorImpl.java:64)
    at org.sonar.application.process.EsManagedProcess.checkStatus(EsManagedProcess.java:92)
    at org.sonar.application.process.EsManagedProcess.checkOperational(EsManagedProcess.java:77)
    at org.sonar.application.process.EsManagedProcess.isOperational(EsManagedProcess.java:62)
    at org.sonar.application.process.ManagedProcessHandler.refreshState(ManagedProcessHandler.java:223)
    at org.sonar.application.process.ManagedProcessHandler$EventWatcher.run(ManagedProcessHandler.java:288)
Caused by: java.util.concurrent.ExecutionException: org.elasticsearch.client.ResponseException: method [GET], host [http://127.0.0.1:9001], URI [/], status line [HTTP/1.1 400 Bad Request]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>

    at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.getValue(BaseFuture.java:257)
    at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.get(BaseFuture.java:244)
    at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:75)
    at org.elasticsearch.client.RestHighLevelClient.performClientRequest(RestHighLevelClient.java:2692)
    ... 10 common frames omitted
Caused by: org.elasticsearch.client.ResponseException: method [GET], host [http://127.0.0.1:9001], URI [/], status line [HTTP/1.1 400 Bad Request]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>

    at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:346)
    at org.elasticsearch.client.RestClient.access$1900(RestClient.java:107)
    at org.elasticsearch.client.RestClient$1.completed(RestClient.java:396)
    at org.elasticsearch.client.RestClient$1.completed(RestClient.java:392)
    at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:122)
    at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:181)
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:448)
    at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:338)
    at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
    at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
    at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
    at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
    at java.base/java.lang.Thread.run(Thread.java:834)

it is trying to access http://127.0.0.1:9001. why it is calling this url? How to solve the above error.

Note : Java version : 11 which is compatible with my SonarQube version : 9.6.1. So, java version is not an issue, also JAVA_HOME environment variable is set

Hey there.

This is where SonarQube hosts its embedded Elasticsearch. You can change this by adjusting sonar.search.port in your conf/sonar.properties file.

And, you shouldn’t be installing SonarQube v9.6.1, which is an EOL version of SonarQube. Please use, at least, SonarQube v9.9 LTS,