AWS / Networking
AWS NAT Gateway costs: why they're high and how to cut them
A NAT gateway has no instance size to pick and nothing to patch. It also bills every hour it exists and every gigabyte that passes through it, including traffic that never leaves AWS.
How a NAT gateway is billed
Instances in a private subnet reach the internet through a NAT gateway. AWS charges for each hour the gateway is available and for each gigabyte it processes. Both charges apply whether the traffic goes to the internet or to another AWS service.
In US East (Ohio), the Amazon VPC pricing page lists $0.045 per NAT gateway-hour and $0.045 per GB processed. Prices vary by Region, so check yours before reusing the numbers below.
At 730 hours a month, one gateway costs about $32.85 before it processes a single byte. Every 100 GB that goes through it adds $4.50 of processing. Traffic to the internet also pays normal data transfer out on top of that.
There is no stop button. The NAT gateway API has create and delete operations, so a gateway in an idle environment keeps billing until someone deletes it.
Where the surprises come from
One gateway per Availability Zone
Each NAT gateway lives in one Availability Zone. For resilience, AWS recommends a NAT gateway in each zone, with routes that keep traffic in its own zone. A three-zone VPC built that way runs three gateways and about $98.55 a month in hourly charges alone in Ohio.
AWS also offers a regional NAT gateway. The pricing page bills it per hour for each Availability Zone it is configured in, at the same $0.045 in Ohio, so it does not remove the per-zone cost.
AWS service traffic going through NAT
Without an endpoint, a private instance reaches S3 or DynamoDB through the NAT gateway. The VPC pricing page's Ohio example shows a 1 GB transfer to S3 paying the $0.045 processing charge, while the transfer itself to S3 in the same Region has no data transfer charge.
Container images add to this. Amazon ECR stores image layers in S3, so every node that pulls an image without endpoints sends those layers through the NAT gateway. Nodes that scale often and CI runners that pull large images repeat those downloads.
Cross-AZ data transfer
When an instance uses a NAT gateway in a different zone, the traffic also crosses zones. AWS charges $0.01 per GB in each direction for that, so roughly $0.02 per GB on top of NAT processing.
Idle dev environments that run 24/7
A dev or preview VPC built from the production template gets the same gateways. The hourly charge does not depend on traffic, so a VPC nobody touches at night or on weekends costs the same as a busy one. Stopping the databases and instances inside it does not change that.
Find the cost before changing anything
In Cost Explorer, NAT gateways appear under EC2 - Other rather than EC2 - Instances. Filter by usage type group on EC2: NAT Gateway - Running Hours and EC2: NAT Gateway - Data Processed. If hours dominate, you have too many gateways. If data processed dominates, look at what sends the traffic.
The underlying usage types carry a Region prefix, such as USE2-NatGateway-Hours and USE2-NatGateway-Bytes in Ohio. Group by usage type to see each Region separately.
Then list the gateways in each Region, with the VPC and subnet they belong to:
aws ec2 describe-nat-gateways \
--filter Name=state,Values=available \
--query "NatGateways[].[NatGatewayId,VpcId,SubnetId,Tags[?Key=='Name']|[0].Value]" \
--output tableTo find which instances send the traffic, enable VPC Flow Logs and use the CloudWatch Logs Insights NAT gateway queries. Replace x.x.x.x with the gateway's private IP and y.y. with the first two octets of the VPC CIDR:
filter (dstAddr like 'x.x.x.x' and srcAddr like 'y.y.')
| stats sum(bytes) as bytesTransferred by srcAddr, dstAddr
| sort bytesTransferred desc
| limit 10Resolve the destination addresses. If the largest ones belong to S3, DynamoDB or ECR, an endpoint will remove most of the processing charge.
Ways to reduce NAT gateway cost
Add gateway endpoints for S3 and DynamoDB
Gateway endpoints exist for S3 and DynamoDB only, and AWS states there is no additional charge for them. They work by adding a route to the route tables you select, so traffic from those subnets to the service skips the NAT gateway:
aws ec2 create-vpc-endpoint \
--vpc-id vpc-0123456789abcdef0 \
--vpc-endpoint-type Gateway \
--service-name com.amazonaws.us-east-2.s3 \
--route-table-ids rtb-0123456789abcdef0 rtb-0fedcba9876543210Endpoint routes apply only to the service in the same Region. Traffic to a bucket in another Region still takes the default route. The ECR documentation also warns that existing S3 connections can be briefly interrupted when the endpoint is added.
Use interface endpoints where the volume justifies them
Other services, including the ECR API and registry, use interface endpoints. These are not free. In Ohio, the AWS price list shows $0.01 per endpoint per Availability Zone per hour, plus $0.01 per GB for the first petabyte. AWS PrivateLink pricing has the details.
One endpoint in three zones costs about $21.90 a month before data. Compared with $0.045 per GB through NAT, it saves $0.035 per GB, so it pays for itself above roughly 630 GB a month to that service. ECR needs two interface endpoints, ecr.api and ecr.dkr, in addition to the S3 gateway endpoint. Small dev VPCs often do not reach that volume.
Run a single NAT gateway outside production
A dev or test VPC can usually accept losing internet access if one zone fails. One gateway instead of three saves $65.70 a month in Ohio hourly charges. Instances in the other zones then pay cross-AZ transfer, so this suits environments with modest internet traffic.
Send IPv6 traffic through an egress-only internet gateway
An egress-only internet gateway gives instances outbound-only IPv6 access. AWS charges nothing for the gateway itself; normal data transfer charges still apply. Traffic to destinations that support IPv6 can skip NAT processing. Anything that only speaks IPv4 still needs a NAT gateway.
Consider a NAT instance, with its trade-offs
A NAT instance is an EC2 instance you configure to translate addresses. AWS bills it like any instance, by type and duration, with no per-GB processing charge. In exchange, you patch it, size its bandwidth and script failover yourself. AWS recommends NAT gateways for that reason. A small NAT instance can make sense in a dev VPC where an outage is acceptable.
Delete NAT gateways in idle environments
If an environment sits unused for days or weeks, delete its NAT gateway and recreate it from infrastructure code when needed. Deleting a gateway leaves its Elastic IP address allocated and its routes in a blackhole state. Release the address if you no longer need it: the VPC pricing page bills an idle public IPv4 address at $0.005 per hour.
A worked monthly example
Take a dev VPC in US East (Ohio) across three Availability Zones, with one NAT gateway per zone. Each month, private subnets send 1,800 GB through NAT: 1,200 GB to S3 and ECR image layers, and 600 GB to the internet. Internet data transfer out is the same in both cases and is left out.
The change adds an S3 gateway endpoint and keeps one NAT gateway. Two-thirds of the remaining internet traffic, 400 GB, now crosses a zone to reach it.
| Line item | Before | After |
|---|---|---|
| NAT gateway hours | 3 × 730 h × $0.045 = $98.55 | 1 × 730 h × $0.045 = $32.85 |
| NAT data processing | 1,800 GB × $0.045 = $81.00 | 600 GB × $0.045 = $27.00 |
| S3 gateway endpoint | None | $0.00 |
| Cross-AZ transfer to the NAT | $0.00 | 400 GB × $0.02 = $8.00 |
| Total per month | $179.55 | $67.85 |
The VPC goes from $179.55 to $67.85 a month, a saving of $111.70, or about 62%. Across ten similar dev and preview VPCs, that is over $1,100 a month. Your numbers depend on Region, traffic mix and how many zones you keep.
Scheduling does not remove NAT charges
SnoozeDB stops non-production RDS databases and EC2 instances outside working hours and can hibernate dev/test EKS clusters. It does not manage NAT gateways. A scheduled environment still pays the NAT gateway hourly charge overnight, even though it processes less data while its instances are stopped.
Treat the two as separate jobs: schedule the compute and databases, and fix the network design with endpoints, fewer gateways or deletion. The EKS scale-to-zero article lists the other costs that remain when workers are gone, and the guide to development environment cost optimization covers the rest of a dev account.
A short checklist
- Split NAT gateway hours from data processed in Cost Explorer, per Region.
- List every NAT gateway with its VPC, and mark the ones in non-production VPCs.
- Add S3 and DynamoDB gateway endpoints to every VPC with private subnets.
- Use flow logs to find the top senders, and add interface endpoints only where volume justifies them.
- Keep one NAT gateway in dev and test VPCs that can tolerate a zone failure.
- Delete gateways in environments that sit idle, and release their Elastic IP addresses.
For other sources of waste in the same accounts, see AWS cost optimization and cloud waste.