Call to URL [***/api/v2/analysis/version] failed: Connect timed out

I set up the SonerQube Server and pushed from GitHub, and now I can build and analyze, but I get the following error during build and analysis.

  • sonar-scanner.bat

    ERROR Failed to query server version: Call to URL [***/api/v2/analysis/version] failed: Connect timed out

Hi,

That’s the first call the scanner makes to the server. It indicates that the sonar.host.url value you’re passing in to analysis isn’t correct.

 
HTH,
Ann

I have set the SONAR_HOST_URL as displayed on the SonarQube Server at http://localhost:9000/tutorials?id=sunflowerApp&selectedTutorial=github-actions, but I am getting the same error.
It now says Call to URL [***/api/v2/analysis/version] failed: No route to host.
How can I resolve this error?

Even if I set the following value for SONAR_HOST_URL on Windows and Linux, a similar error occurs and static analysis has never been performed.

http://localhost:9000
http://127.0.0.1:9000
http://IP address (local IP address that can be communicated with):9000

Hi,

localhost means “this machine that I’m running the command on.” Are you running analysis on the same machine where SonarQube itself is hosted?

 
Ann

Yes, it is running on the same PC.

Hi,

So when you open a browser window on that machine and try to access the URL directly, what do you get?

 
Ann

Hi,

So when you put http://localhost:9000 in a browser, you get a 404?

 
Ann

Hi Ann.

So when you put http://localhost:9000 in a browser, you get a 404?

No, if you enter http://localhost:9000 in your browser you will be taken to the SonarQube login screen.

In this state, the error displayed on GitHub is as follows:

ERROR Failed to query server version: Call to URL [***/api/v2/analysis/version] failed: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:9000

Hi,

But you said the analysis is running on the same machine as SonarQube. How does GitHub come into this?

 
Ann

GitHub is also open in the browser on the same machine, and after selecting the repository when logging in to SonarQube, I select “With GitHub Actions” and set SONAR_TOKEN and SONER_HOST_URL (http://localhost:9000) to GitHub as displayed on the SonarQube screen.
After that, when I pushed source to GitHub, analysis was performed and a red cross was displayed on the pushed source, and the following error was displayed when I opened the details.

ERROR Failed to query server version: Call to URL [***/api/v2/analysis/version] failed: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:9000

Hi,

All I can tell you is that setting a sonar.host.url of localhost is only going to work if everything is running on the same host. Otherwise, you should use the domain name or IP address of the SonarQube host.

 
HTH,
Ann

Hi,

I’m running everything on the same host, and I get an error when I use both localhost and the SonarQube IP address.
Please let me know what possible solutions I can use to resolve this error.

Hi,

You’ve mentioned GitHub Actions. Are you saying you’re running GitHub Actions (the CI) on the same host? And you’re using GitHub Enterprise, and it, too is on that same host?

You get the same error? For that, you might need to talk to your network folks.

 
Ann

Hi,
I don’t know where GitHub Actions is running, but all operations are performed on the same host.
We are currently using the free version of GitHub as we are currently investigating.

Hi Yamamoto,
If you click on the Workflow file link in the left side navigation panel of the GitHub log trace screen, it’ll take you to the YAML configuration file for the GitHub action you’re running.

Please look into runs-on: config which tells whether the GitHub action is running.
If you’re using private GitHub repositories, most likely the machines that is running this GitHub action would also be a private instance.

If your GitHub action has to scan the source code and publish the report to SonarQube Server which is usually hosted in a different domain (private use case scenario, again), you need to use that domain/host URL for defining SONAR_HOST_URL environment variable of this GitHub action.

To clarify and resolve the issue quickly, kindly share the GitHub action’s YAML (file name with .yml extension) and details about the SonarQube server i.e. whether it’s hosted as a private/internal server or publicly accessible etc.

Regards,
B.

Hi Regards,

I will send you the YAML for the GitHub action for now.
The SonarQube server is running as an internal server.
build.zip (595 Bytes)

Hi everyone,

Masa, did you get the GitHub workflow success? I am facing the same error.