Interview Prep/Networking/DNS resolution failures

Java service keeps connecting to an old IP long after the DNS record changed.

IntermediateTroubleshootingDNS resolution failures
Answer

Likely causes → JVM DNS cache. With a security manager installed, networkaddress.cache.ttl defaults to forever; otherwise 30 s. Connection pools also keep existing connections to the old IP.

Diagnose →

jcmd <pid> VM.system_properties | grep -i networkaddress
grep -i networkaddress $JAVA_HOME/conf/security/java.security
ss -tnp | grep java

Fix → Set networkaddress.cache.ttl=60 in java.security or -Dsun.net.inetaddr.ttl=60, and set pool max connection lifetime so connections reopen.

Prevent → Standardize JVM DNS TTL in base images.

All Networking questions Roadmap: Networking for DevOps

More on DNS resolution failures