Skip to main content

Allow-Listing an RDS Instance's IP Address in a Firewall Cuts Clients Off After a Multi-AZ Failover

High severityAmazon Web Services About 20 minutes to fix

Overview

The instance is available and the failover event has fired, yet clients behind a firewall time out. The rule still names the address RDS used before the failover.

At a glance

Symptom
After an automatic failover or a reboot with failover, the instance returns to available and the events list shows the failover completed.
Likely cause
When RDS creates an instance in a VPC it assigns a network interface with an address from the DB subnet group.
Impact
Failover typically takes 60 to 120 seconds, and the address stays changed after that.
Verification signal
From a client behind the firewall, connect using the endpoint name and the database port and log in.
Safe correction
Work in this order, so that at no step a client loses its path before the replacement exists.
Rollback or recovery
The correction touches the firewall and client configuration, not the database.

Firewall rules are written in IP addresses, and an RDS endpoint resolves to one, so pasting that address into an allow list feels like the tidy, least-privilege choice. It works for weeks. Then RDS fails the instance over to its standby, the address behind the endpoint changes, and every client the firewall guards is cut off while the console says the database is available.

AWS says this in so many words: the IP address underneath an RDS endpoint changes during failover, and it strongly recommends connecting by DNS name. The fix is to put the name first and to scope network rules to the subnets RDS can choose from, never to one address and never to the whole internet.

Symptom

After an automatic failover or a reboot with failover, the instance returns to available and the events list shows the failover completed. Yet connections from one network segment time out. These are the clients that sit behind a firewall, a partner’s allow list or a hardened egress rule, and their rules name an IP address.

Nothing is wrong with the database. Clients inside the VPC, going through the security group, may connect normally. The pattern that gives it away is that the outage follows the failover event and affects only paths controlled by address-based rules.

Why a single-address rule looks safe

An address is easy to treat as an identity. Someone resolves the endpoint, sees one address, and writes a /32 rule for it, which reads as the narrowest rule possible. It also keeps working through every ordinary day, so the change passes review and nobody connects it to the failover test that was never run.

The same belief hides in client configuration. A connection string or hosts file that holds the address, rather than the endpoint name, carries the same expiry date. Java clients add a variant: the JVM caches the lookup, and on some configurations never refreshes it until restart.

Root cause

When RDS creates an instance in a VPC it assigns a network interface with an address from the DB subnet group. From that group it chooses a subnet and an address within it. If the primary of a Multi-AZ deployment fails, RDS can promote the standby and later build a new standby using an address in a subnet in another Availability Zone.

So the address is an implementation detail that moves. Failover also changes the DNS record of the instance to point at the standby, which is why the name keeps working and the address does not.

For a publicly accessible instance the same name resolves to the private address inside the VPC and the public address outside it. RDS manages the public Elastic IPv4 addresses itself, and AWS documents that they cannot be modified or released, so there is nothing to pin.

Impact

Failover typically takes 60 to 120 seconds, and the address stays changed after that. A /32 rule written for the old address no longer matches the address clients are sent to, so their traffic is dropped. The outage lasts until someone notices and edits the firewall, which usually means a failure arriving during an incident that already had people’s attention.

The address can also move without an outage you caused. AWS lists failover and compute scaling as maintenance activities that use spare addresses in the DB subnet group, so a rule that survived last quarter is not evidence that it is correct.

How to confirm the rule is stale

These checks are read-only. Start with the instance’s endpoint, zones and access setting:

aws rds describe-db-instances --db-instance-identifier mydbinstance --query 'DBInstances[0].[Endpoint.Address,Endpoint.Port,MultiAZ,AvailabilityZone,SecondaryAvailabilityZone,PubliclyAccessible]'

Do not use the zone values to decide whether a failover happened. AWS notes that the console and API can take several minutes to show the new zone after failover. Use the events, which include a failover started message (RDS-EVENT-0013) and a failover completed message (RDS-EVENT-0049):

aws rds describe-events --source-type db-instance --source-identifier mydbinstance --duration 1440

Then resolve the endpoint from a host on the failing clients’ network path and compare the answer with the address in the rule:

nslookup mydbinstance.abcexample.us-west-2.rds.amazonaws.com

A mismatch confirms the diagnosis. To plan the repair, list the DB subnet group’s subnets, then read their CIDR blocks:

aws rds describe-db-instances --db-instance-identifier mydbinstance --query 'DBInstances[0].DBSubnetGroup.Subnets[].SubnetIdentifier'
aws ec2 describe-subnets --subnet-ids subnet-0example1 subnet-0example2 --query 'Subnets[].[SubnetId,CidrBlock]'

Why opening the port wider makes it worse

Under pressure the quick fix is to add the new address next to the old one, or to give up and allow 0.0.0.0/0 on the database port. Adding addresses only repeats the trap at the next failover.

Opening the port removes the control entirely. AWS documents that network access to a DB instance is off by default and that security group rules are what allow it. Those rules can only allow traffic, never deny it, so a 0.0.0.0/0 entry cannot be narrowed by another security group rule.

Switching on public access to dodge the firewall is a different trap with its own timing, covered in RDS PubliclyAccessible changes are asynchronous. And an allow rule for a whole VPC range is wider than it needs to be: the safe scope is the DB subnet group.

Correction

Work in this order, so that at no step a client loses its path before the replacement exists. Do the first full pass in a non-production copy of the instance.

  1. Record and back up. Note the endpoint, port, DB subnet group subnets and CIDR blocks, and every place an address appears: firewall rules, partner allow lists, hosts files, connection strings. Export the firewall’s current rule set with its own tooling. Do not change the RDS instance for this fix.
  2. Move clients to the endpoint name. Replace any hard-coded address with the DNS name. For Java clients, set networkaddress.cache.ttl to 60 or less in the java.security file or in initialisation code, as AWS recommends. Rollback: restore the previous configuration value.
  3. Add the new rule beside the old. On the firewall, add an allow rule for the database port only, with the destination covering every subnet CIDR in the DB subnet group. Where the clients are inside the VPC, prefer a security group rule that names the application’s security group as its source, which AWS documents as allowing traffic from the instances that use it. Rollback: delete the new rule; the old one is still in place.
  4. Prove it survives a failover. In the non-production copy, stop transactions, check the status is available and run aws rds reboot-db-instance --db-instance-identifier mydbinstance --force-failover. Wait for the failover completed event and reconnect. Rollback: reboot with failover again to return operations to the original zone, with transactions stopped first.
  5. Remove the old /32 rule last. Once the name-based clients pass through the new rule, delete the old entry. Rollback: re-import the exported rule set.

Following along? Tap a step’s number to tick it off.

Verification

From a client behind the firewall, connect using the endpoint name and the database port and log in. Resolve the endpoint again and confirm that no rule, config file or connection string holds an address the name no longer resolves to. After a test failover, look for the completed event, reconnect without touching any rule, and check that the session works from every Availability Zone your clients run in.

Rollback

The correction touches the firewall and client configuration, not the database. Keep the exported rule set and the previous client values until the failover test has passed. If the new rule is too narrow, add the missing subnet; if it is wrong, delete it and the old rule carries on. A forced failover test is reversed by rebooting with failover once more, and any open sessions will drop on each reboot.

Stop it happening again

  • Ban address-based rules for RDS in review. A rule may name the endpoint’s subnets and a port, never one address.
  • Put a failover test in the change checklist for any new network path to a Multi-AZ instance, and treat a path that has never survived one as unproven.
  • Keep the DB subnet group in dedicated subnets with spare addresses, because AWS asks for at least one reserved address per subnet for recovery actions. Do not mix public and private subnets in the group.
  • Alert on the failover completed event and follow it with a connection probe from each firewall zone, so a stale rule shows up in minutes. For a related timeout pattern after a network rule change, see ALB targets unhealthy with Target.Timeout after a security group change.
3

Apply the safer control

Before you change production

Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.

Fix commands and configuration

available
aws rds describe-db-instances --db-instance-identifier mydbinstance --query 'DBInstances[0].[Endpoint.Address,Endpoint.Port,MultiAZ,AvailabilityZone,SecondaryAvailabilityZone,PubliclyAccessible]'
aws rds describe-events --source-type db-instance --source-identifier mydbinstance --duration 1440
4

When to escalate

Validation and rollback are covered in the sections above.

Escalate

Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.

The KBY Brief

Fixed? Get the next one before it hits you: The KBY Brief

Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.

About this page

Credited to

Dates

Published

Corrections

No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

Found this useful? Follow KBY for more like it.

After remediation

Further reading stays below the corrective workflow and is selected by platform, category and shared technical keywords.

More from KBY that goes with this config trap.

Discover more

Connected KBY resources