After a database was migrated to a new host behind the same DNS name, one Java service keeps connecting to the old IP until it's restarted.
IntermediateTroubleshootingDNS, TLS and certificates
Answer
Likely causes → The application caches DNS too long. The JVM caches lookups per networkaddress.cache.ttl (forever when a SecurityManager is installed, 30 seconds by default otherwise, but frameworks and connection pools often resolve once and keep the address). Long-lived pooled connections also never re-resolve.
Diagnose →
kubectl exec deploy/billing -- getent hosts db.internal.example.com
kubectl exec deploy/billing -- ss -tnp | grep 5432 # which IP it's really connected to
Check java.security for networkaddress.cache.ttl and the pool's max connection lifetime.
Fix → Restart the service now. Then set networkaddress.cache.ttl=30 and a pool maxLifetime (HikariCP default 30 minutes) so connections recycle and re-resolve.
Prevent → Include "who caches this DNS name?" in every migration plan, and keep the old endpoint alive (or redirecting) until all clients have moved.
More on DNS, TLS and certificates
Monday morning every browser shows "NET::ERR_CERT_DATE_INVALID" for app.example.com; the cert is from Let's Encrypt via cert-manager.BeginnerYou changed the A record for api.example.com to a new load balancer an hour ago, but some users still reach the old server.BeginnerA cert-manager Certificate is stuck at "Issuing"; the Challenge says "Waiting for HTTP-01 challenge propagation: wrong status code '404', expected '200'".IntermediateAfter switching to a slim base image, the service fails every outbound HTTPS call with "x509: certificate signed by unknown authority".BeginnerBrowsers load the site fine, but Android apps and `curl` from servers fail with "unable to verify the first certificate" or "unable to get local issuer certificate".Intermediate`https://example.com` works, but `https://www.example.com` shows "NET::ERR_CERT_COMMON_NAME_INVALID".Beginner