UnknownHostException ☕ Java

java.net.UnknownHostException: api.example.com

DNS resolution failed for the hostname.

Seen on: Java

Meaning

Typos, internal hostnames not resolvable from this machine, missing DNS inside containers or no network.

Common causes

  • Hostname typo or protocol included
  • Internal DNS / VPN required
  • Container DNS misconfigured
  • Offline

⚡ Quick fix

  1. nslookup the host from the same machine
  2. Fix the configured URL
  3. Check container DNS

Detailed fix by platform

Linux

  1. nslookup api.example.com

How to diagnose

  1. Host — Exact name
  2. DNS — Resolves here?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.