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.
ERROR: Error during SonarScanner execution
ERROR: Caused by: sonarqube.interal (a typo) : java.net.UnknownHostException: sonarqube.interalCommon 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
- Check SONAR_HOST_URL character by character for typos.
- Confirm the hostname resolves from the runner with a DNS lookup.
- Fix the value and re-run.
getent hosts sonarqube.internal || nslookup sonarqube.internalMake 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.