Getting error while integration SonarQube with Azure DevOps


I integrated SonarQube with Azure DevOps. Created a pipeline and added ‘Prepare SonarQube analysis’ task in the pipeline. But the task fails with the below error. I have followed all the steps of integration and SonarQube server is running. The error pipeline generates is as follows:
##[error][SQ] API GET ‘/api/server/version’ failed, error was: {“errno”:“ECONNREFUSED”,“code”:“ECONNREFUSED”,“syscall”:“connect”,“address”:“”,“port”:9000}

Does the Azure DevOps build agent have access to the SonarQube server over the network?

Both installed and accessed in same system. Is there any specific setting to check Azure build agent configuration.

It’s sounds like purely a networking configuration matter, rather than a setting on the Azure DevOps build agent.

What URL do you normally access your SonarQube server over? localhost:9000, or something else?

I use localhost:9000 to access my SonarQube server.

I suggest taking the task out of the equation entirely and querying localhost:9000/api/sever/version via a curl or Invoke-WebRequest in the context of your pipeline to see if you also get a refused connection.

I get an error ’ SonarQube server [http://localhost:9000] can not be reached’ with the Invoke-WebRequest on my pipeline.
My SonarQube server is up and running and I am able to access the dashboard.

It sounds like maybe you have Azure DevOps and SonarQube installed on the same server, but an Azure DevOps build agent installed separately. Is that possible?

That could be possible. Are there any specific steps to install the build agent on the same machine.

That’s certainly one way to address it (you’ll have to refer to Azure DevOps docs and support) – and, more commonly, you would expose your SonarQube server hosted on port 9000 to the internet (or at least to other resources on your intranet) so that it can be accessed by many build agents, and users not just on the machine it’s hosted.