---
title: "Clients still use the old address after a database failover | Proofline"
description: "After a failover moves a DNS name, a client keeps the old address if its runtime cached the lookup or its pool holds connections opened before the move."
url: https://proofline.sh/learn/dns-client-caches-old-address-after-failover/
---

[Learning center](/learn/)

# Clients still use the old address after a database failover

After a failover moves a DNS name, a client keeps the old address if its runtime cached the lookup or its pool holds connections opened before the move. Compare the address the name resolves to now with the remote addresses of the service's open connections. If they differ, the client is stuck on the old endpoint; if they match and requests still fail, the new endpoint is the problem.

Network outages The Proofline team November 23, 2026 5 min read

## The symptom

RDS reports a Multi-AZ failover at 03:12 UTC. Most services recover within a minute, but `payments` keeps failing with connection timeouts or resets to the database until someone restarts it at 03:40. Or a Redis or search endpoint is replaced, and one service keeps writing to a node that no longer takes writes.

In a Multi-AZ DB instance failover, RDS changes the DNS record of the DB instance to point at the standby, and AWS notes that you need to re-establish existing connections. The endpoint name stays the same; the address behind it changes. [RDS Multi-AZ failover](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZ.Failover.html)

Two client-side mechanisms keep the old address:

-   A cached lookup: the runtime resolved the name before the failover and keeps using that result for its own TTL, regardless of the DNS record's TTL.
-   Held connections: the pool opened connections to the old address and keeps reusing them. Each new request goes to the old host, and DNS is never consulted again.

And one cause looks the same but is not a client cache: the client follows the name correctly, and the new endpoint is not accepting connections yet.

## Where clients hold an old address

The JVM caches successful lookups in its own cache, controlled by the security property `networkaddress.cache.ttl`. Oracle's documentation says the default is to cache forever when a security manager is installed and is implementation-specific otherwise. It is a security property, so `-D` on the command line does not set it; it lives in the `java.security` file or is set with `Security.setProperty`. AWS recommends a TTL of no more than 60 seconds for RDS, and its SDK guide recommends 5 seconds. [Java networking properties](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/doc-files/net-properties.html) · [RDS: setting the JVM TTL](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZ.Failover.html) · [AWS SDK for Java: JVM TTL](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/jvm-ttl-dns.html)

Connection pools are the more common culprit. Go's `database/sql` reuses connections without an age limit unless `SetConnMaxLifetime` is set, and other pools have similar maximum-lifetime settings. A connection to a host that went away without closing it can hang until the TCP stack gives up on it. [Go database/sql](https://pkg.go.dev/database/sql)

For Aurora, AWS recommends that clients caching DNS data for DB instances use a TTL of less than 30 seconds, because the address behind an endpoint can change after a failover. [Aurora best practices](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.BestPractices.html)

## Compare the resolved address with the open connections

Confirm the failover time from the event log first. RDS publishes events when a Multi-AZ failover starts and when it completes, and the completed event is the authoritative indicator that it is done. [describe-events](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-events.html)

```
aws rds describe-events \
  --profile PROFILE --region REGION \
  --source-type db-instance --source-identifier DB_INSTANCE_ID --duration 180 \
  --query 'Events[].{date:Date,message:Message}' --output table --no-cli-pager
```

Then, inside an affected container or host, resolve the endpoint the way the system does and list the connections to the database port. `ss -tn` prints each TCP socket with its state and peer address; `-p` adds the owning process if you have permission. [ss(8)](https://man7.org/linux/man-pages/man8/ss.8.html) · [getent(1)](https://man7.org/linux/man-pages/man1/getent.1.html)

```
getent ahosts DB_ENDPOINT
dig +short DB_ENDPOINT

ss -tn '( dport = :5432 )'
```

On ECS or Kubernetes, run these through ECS Exec or `kubectl exec` in a failing task and in a healthy one. If the image has no `ss`, `/proc/net/tcp` holds the same table in hexadecimal. [Exec into an ECS task](/learn/dependency-timeouts-only-from-new-tasks/#same-connection)

For a JVM, read what the process actually uses for the cache TTL. `Security.getProperty("networkaddress.cache.ttl")` from inside the application prints it; from outside, read the `java.security` file of the JDK the process runs and check for a programmatic override in the code.

## Read the result

| Resolved now | Open connections | Points to |
| --- | --- | --- |
| New address | Old address | The pool kept connections; they need closing or a max lifetime |
| Old address in the app, new in getent | Old address | The runtime's DNS cache |
| New address | New address, still failing | The new endpoint or its path, not a client cache |
| Old address everywhere | Old address | DNS has not changed, or a resolver cache still serves the old record |

For the last row, query the authoritative answer and the TTL the resolver returns. A resolver may still hold the old record until its TTL expires. [NXDOMAIN, SERVFAIL or no answer](/learn/dns-nxdomain-servfail-timeout/)

## A worked example: one failover, two services

This example is illustrative. The RDS instance `orders-db` fails over at 03:12:40 UTC; the completed event is at 03:13:55. Before the failover, the endpoint resolved to 10.0.21.15; afterwards to 10.0.37.9.

The `orders` service, written in Go, recovers at 03:14. The `payments` service, on the JVM, does not. Inside a `payments` task at 03:20:

| Check | Result |
| --- | --- |
| `getent ahosts` for the endpoint | 10.0.37.9 |
| `ss -tn` to port 5432 | `SYN-SENT` to 10.0.21.15, nothing to 10.0.37.9 |
| `networkaddress.cache.ttl` | set to -1 in the image's `java.security` |

The system resolver has the new address, but the JVM caches forever, so every reconnect attempt goes back to 10.0.21.15 and never completes. A restart at 03:40 fixes it by clearing the cache. The lasting fix is a short TTL in the image's `java.security` and a pool maximum lifetime.

At a later failover, the same check on `payments` shows both the resolved address and the open connections at the new address, and new sessions still fail. The client is following the name correctly. The new primary was still finishing recovery, so this time the database side needs a look, not the client. [Connection refused or timeout](/learn/connection-refused-vs-timeout/)

## Limits

A matching address does not prove a healthy connection. Where the old primary rejoins as a replica, a client that kept its connections reaches a live node that refuses writes, which looks like an application error rather than a network one. Check the role of the node behind the address. [Redis read-only replica after failover](/learn/redis-readonly-replica-after-failover/)

`ss` shows connections at one moment. Run it twice: a pool that drains old connections shows them disappearing, a stuck one shows the same sockets.

Behind a proxy such as RDS Proxy or PgBouncer, the client's connections go to the proxy, and the old-address question moves to the proxy's own connections. For the rest of the dependency checks, see [runtime dependency failures](/learn/runtime-dependency-failures/).

## Questions

### Why did restarting the service fix the failover?

A restart empties the runtime's DNS cache and the connection pool, so the service resolves the name again and opens new connections to the new address. It hides which of the two caches held the old address; compare `ss` with `getent` before restarting.

### Does the DNS record's TTL control the JVM cache?

No. The JVM uses its own `networkaddress.cache.ttl`, not the TTL in the DNS response. A short record TTL does not help a JVM configured to cache forever.

### Do I need a short DNS TTL if the pool keeps connections open?

Both matter. The DNS TTL decides which address a new connection uses; the pool's maximum lifetime decides how long an old connection survives. A failover needs both to move.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Connection refused or timed out: what each error tells you](/learn/connection-refused-vs-timeout/)
    
    Network outages The Proofline team November 23, 2026 6 min read
    
-   ### [Dependency timeouts only from new ECS tasks or Cloud Run revisions](/learn/dependency-timeouts-only-from-new-tasks/)
    
    Network outages The Proofline team November 20, 2026 9 min read
