SonarSource/sonarqube · error · SonarException

Fail to download: %s

Error message

Fail to download: %s

What it means

DefaultHttpDownloader throws this SonarException (wrapped in an HttpException carrying the URI, HTTP status code and response body) when an HTTP download from a remote server fails. It is raised by failToDownload in two cases: any IOException while opening/reading the connection, or a non-successful HTTP response code from the server. The message includes the exact URI that could not be downloaded.

Source

Thrown at sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java:153

  }

  private Response executeCall(URI uri) throws IOException {
    Request request = new Request.Builder().url(uri.toURL()).get().build();
    Response response = client.newCall(request).execute();
    throwExceptionIfResponseIsNotSuccesful(uri, response);
    return response;
  }

  private static void throwExceptionIfResponseIsNotSuccesful(URI uri, Response response) throws IOException {
    if (!response.isSuccessful()) {
      try (ResponseBody responseBody = response.body()) {
        throw new HttpException(uri, response.code(), responseBody.string());
      }
    }
  }

  private static SonarException failToDownload(URI uri, IOException e) {
    throw new SonarException(String.format("Fail to download: %s", uri), e);
  }

}

View on GitHub (pinned to 184c821202)

Solutions

  1. Open the URI from the message in a browser or with curl to see the actual HTTP status/error.
  2. Verify sonar.host.url / sonar.server base URL and network connectivity (DNS, proxy, firewall) from the machine running the download.
  3. If behind a corporate proxy, configure proxy settings for the JVM/analysis process.
  4. Check whether the resource still exists on the server (e.g. plugin update center) and use a valid URL/version.
  5. Check SSL/TLS: add the server certificate to the truststore or fix the keystore configuration if certificate validation fails.

Example fix

// before: assuming download always succeeds
String xml = downloader.readString(URI.create(serverUrl + "/api/rules/show"));
// after: pre-check reachability and handle failure
URI uri = URI.create(serverUrl + "/api/rules/show");
try {
  String xml = downloader.readString(uri);
} catch (SonarException e) {
  LOG.warn("Could not download " + uri + ": " + e.getMessage());
}
Defensive patterns

Strategy: retry

Validate before calling

HttpURLConnection c = (HttpURLConnection) uri.toURL().openConnection();
c.setConnectTimeout(5000);
if (c.getResponseCode() / 100 != 2) {
  throw new IllegalStateException("Resource unavailable: " + c.getResponseCode());
}

Try / catch

try {
  String content = downloader.readString(uri);
} catch (SonarException e) {
  // inspect e.getCause() instanceof HttpException for status code
  LOG.warn("Download failed for " + uri, e);
}

Prevention

When it happens

Trigger: Calling DefaultHttpDownloader.readString(), download(), or openStream() when the target URI is unreachable (DNS failure, connection refused, timeout) or when the server returns a non-2xx status code (404 not found, 403 forbidden, 500 server error).

Common situations: SonarQube server URL misconfigured in sonar.properties; plugin/update-center downloads failing due to a proxy or firewall blocking outbound HTTPS; the remote resource was moved or deleted (404); SSL certificate issues in corporate environments; SonarQube server temporarily down during CI analysis.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/7bb2328ec4655a1f. Report an issue: GitHub.