21

I've recently installed the latest version of Jenkins, SonarQube 6.0 (running on a separate server) and when the Jenkins job attempts to upload sonar scanner results to the SonarQube server, I get the following error:

'ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonarqube.ws.client.HttpException: Error 413 on http://****`

What could be the cause? An error in the sonar-project properties?

G. Ann - SonarSource Team
  • 20,814
  • 3
  • 32
  • 60
  • See [this](http://www.checkupdown.com/status/E413.html) explanation of HTTP 413. Could you tell something about the project size? – Jeroen Heier Sep 15 '16 at 04:30
  • Is SonarQube behing a reverse poxy ? In this case, the configuration may be incorrect. For instance for httpd, if you setup LimitRequestBody parameter (http://httpd.apache.org/docs/2.4/mod/core.html#limitrequestbody) you have reached this limit. – Eric Hartmann Sep 15 '16 at 06:11

4 Answers4

32

I had the same error where my sonarqube server was behind an nginx proxy.

413 == Request entity too large as @jeroen-heier said.

I applied a change to my nginx configuration like this

server {
  ...
  client_max_body_size 20M;
  ....
}

to allow requests to be 20 megabytes, and that fixed it.

Peter Mounce
  • 3,826
  • 1
  • 31
  • 60
  • 1
    Tip#1: The http-server is not shown in sonar's configuration files. You can check if your sonar server is using nginx by running `sudo server nginx stop` and seeing if the url is reachable. Tip#2: In stead of `server {}` it can also be a `http` or `location` block. Look at the [documentation](https://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/) for more info. – leondepeon Feb 27 '17 at 09:56
6

If you run sonar in docker , the default sonar image does not contain nginx server, so there're nothing can do in container

I ran it in k8s, there's a ingress before sonar service, so you should config the ingress and the service

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: sonarqube
  namespace: default
  annotations:
    ingress.kubernetes.io/proxy-body-size: "20M"
spec:
  rules:
...

To get this via the helm chart, add

ingress:
  enabled: true
  annotations:
    ingress.kubernetes.io/proxy-body-size: "20M"
Ben Mathews
  • 2,629
  • 1
  • 17
  • 25
yan
  • 846
  • 9
  • 10
5

In case you're using nginx-ingress, add nginx.ingress.kubernetes.io/proxy-body-size: "20M" into the annotations:

Eric Aya
  • 68,765
  • 33
  • 165
  • 232
  • I was about to add this answer to the post....as I had skipped it when reading the post and have spent quite some time looking for a solution!! I should read more slowly! thanks! – Chexpir Apr 27 '20 at 08:08
-3

Answering my own question. It turned out to be an error in setting the following property in sonar.properties file:

#sonar.web.host=0.0.0.0

Uncommenting and setting to an address means that only clients that have that address can access the sonar qube.

  • 2
    The https 413 error has nothing to do with this! it is something with the size of the payload that needs to be uploaded. If the payload is in kbs, you will not get this error. – Vighnesh Pai Feb 07 '18 at 20:11
  • 2
    Please remove this as the solution. – tdensmore Jun 12 '19 at 15:32
  • It was a long time ago since I posted this and from what I remember, configuring sonar.web.host incorrectly caused the 413 http error. Putting it back to the default shown fixed it. – Mister Tommy Cat Jun 24 '19 at 20:34
  • 1
    @MisterTommyCat based on your last comment I suggest you to edit your initial question, in order to make it clear that even if the 413 error refers to something about exceeding payload, fixing the sonar.web.host parameter fixes the 413 error too. – Marco Apr 28 '20 at 11:07
  • This is not the solution – Sankalan Parajuli Sep 10 '20 at 09:38