Error during SonarScanner execution (sonarqube-scan-action)

Hello everyone,

It is my first time using this kind of tool. I am having some issues during execution. Below are the logs

INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties

INFO: Project root configuration file: NONE

INFO: SonarScanner 4.6.2.2472

INFO: Java 11.0.11 AdoptOpenJDK (64-bit)

INFO: Linux 5.8.0-1039-azure amd64

INFO: User cache: /opt/sonar-scanner/.sonar/cache

ERROR: SonarQube server [***] can not be reached

INFO: ------------------------------------------------------------------------

INFO: EXECUTION FAILURE

INFO: ------------------------------------------------------------------------

INFO: Total time: 0.355s

INFO: Final Memory: 3M/14M

INFO: ------------------------------------------------------------------------

ERROR: Error during SonarScanner execution

org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis

at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)

at java.base/java.security.AccessController.doPrivileged(Native Method)

at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)

at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)

at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)

at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)

at org.sonarsource.scanner.cli.Main.execute(Main.java:73)

at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server

at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)

at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)

at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)

at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)

... 7 more

Caused by: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9000

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:265)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:183)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Transmitter.newExchange(Transmitter.java:169)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)

at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:221)

at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:81)

at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:115)

at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99)

at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)

... 10 more

Caused by: java.net.ConnectException: Connection refused (Connection refused)

at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)

at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)

at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)

at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)

at java.base/java.net.SocksSocketImpl.connect(Unknown Source)

at java.base/java.net.Socket.connect(Unknown Source)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.platform.Platform.connectSocket(Platform.java:130)

at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:263)

... 31 more

ERROR:

ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

What should I do to fix that? Thanks!

Hey there.

The logs indicate that the scanner can’t get in touch with your SonarQube server. Do you have already a SonarQube server up and running (at localhost:9000 or somewhere else) that you can reach via your browser?

Hey Colin,

Thanks for answering.
Yes, the server is working on localhost:9000 and the project has been created waiting answer from GitHub. In the picture you can see external_data_source (based on local directory, this one is working) and external-data-source (the one i want to analyze with GitHub Actions)
Maybe I should have said this before but the error come from an action when pussing on GitHub (private repository).



I hope this clears up some of the doubts!

Does the GitHub Runner have access to your localhost (basically, is it running on the same machine as your SonarQube server)?

yes, same machine

In that case, I would take the scanner out of the mix entirely and work on debugging the connectivity between the runner and your SonarQube server. For example – can you succesfully execute a curl command from your build againist http://localhost:9000/api/server/version?

Sorry Colin, what do you mean by “take the scanner out of the mix entirely and work on debugging the connectivity between the runner and your SonarQube server”.
When I run de curl command I get: 9.0.1.46107

Hey Ignacio, Did you find the answer of above issues?