Skip to content
Latchkey

SonarScanner "java.net.UnknownHostException" for the host URL in CI

The scanner tried to resolve the SonarQube hostname and DNS returned nothing. The host in SONAR_HOST_URL is misspelled, or it is an internal name the runner cannot resolve.

What this error means

The scanner fails with "Caused by: java.net.UnknownHostException: <host>" while trying to reach the server. This is a name resolution failure, not an HTTP error.

sonar-scanner
ERROR: Error during SonarScanner execution
ERROR: Caused by: sonarqube.interal (a typo) : java.net.UnknownHostException: sonarqube.interal

Common causes

A typo in the hostname

A misspelled host in SONAR_HOST_URL (for example "interal" instead of "internal") cannot be resolved.

An internal host not resolvable from the runner

A private SonarQube hostname works inside the network but the CI runner has no DNS route or VPN to resolve it.

How to fix it

Correct the hostname in SONAR_HOST_URL

  1. Check SONAR_HOST_URL character by character for typos.
  2. Confirm the hostname resolves from the runner with a DNS lookup.
  3. Fix the value and re-run.
Terminal
getent hosts sonarqube.internal || nslookup sonarqube.internal

Make the internal host reachable

For a private instance, run analysis on a runner inside the network, or expose the server through a resolvable endpoint the runner can reach.

How to prevent it

  • Store SONAR_HOST_URL centrally so the value is validated once.
  • Use runners that share DNS with the SonarQube host for private instances.
  • Add a DNS resolution check before the scanner step.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →