Insights

Moved to Transit Gateway but Traffic Still Uses the Old Peering? Check Prefix Length

November 9, 2026
0:00
You attached both VPCs to a new Transit Gateway, the hub route tables look right, and connectivity tests pass. Then you check the old VPC peering connection and see it is still carrying traffic. Nobody wants to delete a link that is clearly in use, so the migration stalls. In most cases the cause is not the Transit Gateway at all. It is a leftover route with a longer prefix that still points at the peering.
This problem is easy to miss because nothing is broken. Applications connect, health checks are green, and latency looks normal. The only sign is that the peering connection still shows activity, or that Transit Gateway attachment metrics for the VPCs stay near zero while the application is clearly busy. That is worth taking seriously. If you delete the peering now and the Transit Gateway path has a gap you have not noticed, you find out during an outage instead of during a test. The goal is to prove which path traffic actually takes, and why, before removing anything. A quick reminder of the two pieces involved. A VPC peering connection is a direct, non-transitive link between two VPCs: each side needs a route pointing at it, and it cannot be used to reach a third VPC. A Transit Gateway (TGW) is a regional hub router built for transitive routing between many VPCs and on-premises networks. Both are just targets in a VPC route table. The route table decides which one a packet uses.
A few explanations come up often and are usually wrong. The first is that the Transit Gateway is misconfigured. If the TGW route table has the destination CIDR and the attachments are associated correctly, the hub is ready. But a route in the hub only matters once a packet reaches the hub. Packets leaving an instance are steered by the subnet route table in the VPC first, and that is where the decision happens. The article on checking effective routes when a Transit Gateway shows the route but traffic still drops covers this gap between what the hub shows and what instances use. The second is that enabling route propagation should have taken care of it. Propagation on a Transit Gateway attachment populates the Transit Gateway route table. It does not add routes to your VPC subnet route tables. Those are typically managed by hand, through infrastructure as code, or through a prefix list, depending on the setup. The third is the assumption that the newer or more capable target wins. Route tables have no notion of which target is newer or preferred. When two routes have different prefix lengths, the more specific one wins every time.
Route tables in AWS, like most routers, use longest prefix match. For a given destination IP, every route whose CIDR contains that IP is a candidate, and the one with the longest prefix (the biggest number after the slash) is chosen. A /24 beats a /16, and a /16 beats a /8. A common migration pattern shows how this goes wrong. As an illustrative example, the application VPC is 10.1.0.0/16 and the database VPC is 10.2.0.0/16. During the peering era, the application VPC route table got a route for 10.2.0.0/16 pointing at the peering connection. During the TGW rollout, someone added a single summary route, 10.0.0.0/8, pointing at the Transit Gateway, so every internal VPC is reachable through the hub without one route per VPC. Now a packet to 10.2.5.10 matches both routes. The /16 is more specific than the /8, so it goes over the peering. The /8 route is valid and in place, but it only catches traffic that has no more specific match. For the database VPC, it never does. AWS also blocks the other obvious approach. A single route table generally will not accept two routes with the identical destination CIDR pointing at different targets, so you cannot add 10.2.0.0/16 to the TGW next to the existing peering route. Teams often add a broader route instead, which leaves the peering route shadowing it. The same logic applies in the opposite direction. The database VPC almost certainly has a 10.1.0.0/16 route back to the peering. Fix one side only and requests go out through the TGW while replies come back over the peering. That asymmetric path may well keep working, but it is harder to reason about. It can also break stateful appliances or inspection setups that expect to see both directions.
The check is to list every route table in each VPC, not just the main one. Subnets with an explicit association use their own table, and it is common to update the main route table while the subnets that matter use a custom one. Run this for each VPC involved. It is read-only.
BASH
aws ec2 describe-route-tables \
  --filters 'Name=vpc-id,Values=vpc-0123456789abcdef0' \
  --query 'RouteTables[].{Table:RouteTableId,Subnets:Associations[].SubnetId,Routes:Routes[].[DestinationCidrBlock,VpcPeeringConnectionId,TransitGatewayId,State]}' \
  --output json
For each table, look for any destination that covers the other VPC and note its target. The pattern to look for is a peering route that is more specific than the Transit Gateway route.
TEXT
Illustrative output format (trimmed):
Table: rtb-0aaa...   Subnets: subnet-0app1..., subnet-0app2...
  10.1.0.0/16   local                    active
  10.2.0.0/16   pcx-0bbb...              active   <- more specific, wins
  10.0.0.0/8    tgw-0ccc...              active   <- only used when nothing longer matches
If every table in both VPCs shows the other side's CIDR only via the Transit Gateway, then route selection is not the cause and the peering activity comes from somewhere else. Check for other VPCs, a different subnet tier, or a route table you missed. If a peering route like the one above is present, you have found the root cause. To confirm the result rather than just inferring it from route tables, compare traffic on the two paths. Transit Gateway publishes per-attachment metrics in CloudWatch and supports flow logs, and VPC Flow Logs on the relevant interfaces show the flows themselves. VPC Reachability Analyzer can also trace the path between two resources and report which route and target it used. The exact metric names and options depend on region and account setup, so check what is available in your console.
Once you know which routes are shadowing the hub, the cutover is a matter of order. A sequence that keeps the rollback simple looks like this:
  1. Confirm the Transit Gateway path is ready on its own. Both VPC attachments should be associated with the intended TGW route table, that table should have routes for both VPC CIDRs, and each attachment should have a subnet in every Availability Zone where the workload runs.
  2. Check anything tied to peering beyond routes. Security group rules that reference a security group in the peer VPC are a common example. Depending on your setup, those may not work over a Transit Gateway and might need to become CIDR-based rules first.
  3. In the first VPC, change the target of the specific route from the peering to the Transit Gateway, one route table at a time. Replacing the target keeps the same prefix, so there is no moment where traffic falls through to a different route.
  4. Do the same for the return routes in the other VPC, soon after step 3, to keep the period of asymmetric routing short.
  5. Watch the Transit Gateway attachment metrics rise and peering traffic drop to zero. Leave the peering in place for a while as a fallback.
  6. Only then delete the peering connection.
Step 3 is a single command per route table. It changes live routing, so run it in a maintenance window if the path is critical, and keep the old peering ID nearby for rollback.
BASH
# Changes live routing: replaces the target of an existing route, same prefix
aws ec2 replace-route \
  --route-table-id rtb-0123456789abcdef0 \
  --destination-cidr-block 10.2.0.0/16 \
  --transit-gateway-id tgw-0123456789abcdef0
Rollback is the same command with --vpc-peering-connection-id and the old peering ID, as long as the peering still exists. That is why it should outlive the route changes. Once the peering is deleted, any route still pointing at it becomes a blackhole, and a newly created peering gets a new ID that every route would need to use. An alternative is to delete the specific peering routes and let the broad /8 TGW route take over. It works, but now reachability depends on a summary route that someone may later narrow or remove. Replacing the target keeps the intent explicit: this CIDR goes to the hub. If you want broad coverage as well, keep the summary route as a backstop, not as the main path. From a support point of view, this is the question to ask first when someone says the TGW is live but the peering is still busy: what does the subnet route table actually say for the destination CIDR, and on both sides? It is a faster answer than reviewing the hub configuration again. If the VPCs are attached but still cannot reach each other at all, that is a different issue, covered in why two VPCs peered to the same hub still cannot reach each other. The practical rule is short. A Transit Gateway only receives traffic that the VPC route table sends to it, and the route table always prefers the longest matching prefix. Before you remove any peering, list every route table in both VPCs, move each specific peering route to the Transit Gateway with the same prefix, confirm traffic has shifted using metrics or flow logs, and delete the peering last.

Join My Newsletter & Get Updates!

Get notified whenever a new technical guide, server infrastructure breakdown, or personal reflection goes live, plus a curated weekly digest.