The name didn't resolve to an IP; the server was never contacted.
Check the spelling first.
Kubernetes: a short name only resolves in your own namespace; use service.namespace (or the full .svc.cluster.local name).
Docker: use the compose service name and make sure both containers share a network.
Test from where the app runs: nslookup / getent hosts inside the pod or container.
Java caches lookups (and failures briefly): restart long-running apps after a DNS fix if needed.
✦ Definition~90s read
What is java.net.UnknownHostException?
java.net.UnknownHostException is thrown when Java can't resolve a host name to an IP address. The DNS lookup (or /etc/hosts) returned nothing, so no packet was ever sent to the target.
★
You asked the phone book for a number and it had no entry under that name.
Plain-English First
You asked the phone book for a number and it had no entry under that name. You never got to dial.
A checkout service in a new cluster failed with UnknownHostException: orders-db. The database was running. The app was asking for a short name from the wrong namespace.
Resolution Happens First
Before connecting, Java resolves the host name. If that fails, it throws UnknownHostException and never opens a socket.