Prefer video? The full walkthrough is at the top of this post, and the most common cases have one-minute Shorts right where they come up. This guide first went out on the AWS Cloud in a Minute newsletter.
The one-minute answer
The problem: an instance, container or Lambda function in a private subnet can’t reach S3 or another AWS service. Or it can, and the NAT gateway line on your bill keeps growing.
How AWS decides: a private subnet has no direct route to the internet. Traffic to AWS services leaves it one of three ways: through a NAT gateway, which is charged per hour and per GB; through a gateway endpoint, which works only for S3 and DynamoDB and is free; or through an interface endpoint, which works for most other services and is charged per hour in each Availability Zone and per GB. The subnet’s route table and DNS decide which way each request goes.
Where to look first: the route table of the subnet the workload runs in. If there’s no route to a gateway endpoint for S3, S3 traffic goes to the NAT gateway and you pay for every GB, or, with no NAT gateway, it goes nowhere.
The rest of this guide explains the three paths and what each costs, goes through the causes in the order worth checking, and ends with a checklist.
Three ways out of a private subnet
NAT gateway. A route for 0.0.0.0/0 points at the NAT gateway, and the NAT gateway sends traffic on to the internet, including to public AWS service endpoints. You pay for each hour it exists, used or not, and for each GB it processes. In US East (Ohio), for example, that’s $0.045 per hour and $0.045 per GB. Traffic to S3 in the same Region has no data transfer charge, but the NAT gateway still charges for processing it.
A classic NAT gateway lives in one Availability Zone, in a public subnet with a route to an internet gateway. AWS recommends one per zone, because sending traffic to a NAT gateway in another zone adds cross-zone data charges and ties every zone to that one. Since November 2025 there’s also a regional NAT gateway: one gateway that expands across the zones where you have workloads and doesn’t need a public subnet.
Gateway endpoint. Only for S3 and DynamoDB, and there’s no charge for it. It doesn’t create anything in your subnets. It adds a route to the route tables you associate with it: the destination is the service’s prefix list, such as pl-63a5400a for S3 in us-east-1, and the target is the endpoint. Routing uses the longest prefix match, so this route wins over 0.0.0.0/0 for that service. Three limits matter:
- It covers only buckets and tables in the same Region as the endpoint.
- It can’t be used from the other side of a VPN, Direct Connect, VPC peering or transit gateway connection.
- Only subnets whose route table is associated with it use it. Every other subnet keeps going through the NAT gateway.
Interface endpoint (AWS PrivateLink). For most AWS services, such as STS, SQS, Secrets Manager, ECR and CloudWatch Logs, and also for S3 when you need it from on-premises or another VPC. It puts a network interface with a private IP in each subnet you choose, one per zone, behind a security group. With private DNS on, the service’s normal name resolves to those private IPs, so your code doesn’t change. It costs $0.01 per hour for each network interface and $0.01 per GB for the first petabyte, using the US East (N. Virginia) rates.
Which one to use:
- S3 or DynamoDB in the same Region: a gateway endpoint. It’s free.
- S3 from on-premises or another VPC: an interface endpoint for S3.
- Another AWS service with a lot of traffic: an interface endpoint, at $0.01 per GB instead of the NAT gateway’s $0.045.
- Anything outside AWS, such as package repositories or third-party APIs: the NAT gateway.
A quick sum shows the difference. One terabyte a month from a private subnet to S3 costs about $45 in NAT gateway processing alone, and nothing through a gateway endpoint. An interface endpoint in three zones costs about $22 a month for the hours (3 × 730 × $0.01), plus its per-GB charge, so for a service with little traffic, the NAT gateway you already pay for can be cheaper.
The causes, one by one
Check them in this order. The first five are about S3 and DynamoDB, the next two about interface endpoints, then the NAT gateway itself, and the last three are about cost.
It can’t reach S3 or DynamoDB
1. The gateway endpoint isn’t on this subnet’s route table. A gateway endpoint is associated with route tables, not subnets. If the workload’s subnet uses a different route table, S3 traffic goes to the NAT gateway, or nowhere. A subnet without its own route table uses the VPC’s main route table, which is easy to miss.
Fix: associate the subnet’s route table with the endpoint. Look for a route whose destination starts with pl- and whose target starts with vpce-.
The classic case is a Lambda function in a VPC, in under a minute:
2. The bucket is in another Region. Prefix lists are per Region, so a gateway endpoint in us-east-1 does nothing for a bucket in eu-west-1. That traffic goes to the NAT gateway, and in a subnet without one, it fails. It also happens when the SDK or CLI is set to the wrong Region.
Fix: set the Region your code uses to the bucket’s Region, keep data and workloads in the same Region, or accept the NAT path for that traffic.
3. The endpoint policy blocks it. The default endpoint policy allows full access. Once someone narrows it to a list of buckets, every other bucket is blocked through that endpoint, including ones you forgot you depend on.
Fix: read the endpoint policy and add the bucket you need.
4. The bucket policy blocks it. Requests through an endpoint reach S3 from your VPC’s private IP addresses, not your NAT gateway’s public IP. A bucket policy that allows access with aws:SourceIp, such as your NAT gateway’s Elastic IP, stops matching, because that key isn’t available for requests that come through a VPC endpoint.
Fix: use aws:SourceVpce with the endpoint ID, or aws:SourceVpc with the VPC ID. Be careful with Deny statements that use them: a Deny for everything not coming from your endpoint also blocks the console, and can lock you out of the bucket.
5. A security group or network ACL blocks it. If outbound rules are restricted, the instance’s security group needs to allow port 443 to the S3 prefix list. Network ACLs can’t reference prefix lists, so they need the service’s IP ranges instead.
Fix: allow outbound 443 to the prefix list in the security group, and to the service’s CIDR blocks in the network ACL.
It can’t reach other AWS services
6. The name still resolves to a public IP. For an interface endpoint to be used, the service’s name has to resolve to the endpoint’s private IPs. That needs private DNS enabled on the endpoint, and DNS resolution and DNS hostnames enabled on the VPC. Otherwise the request goes to the public endpoint through the NAT gateway, or fails without one.
Fix: enable private DNS on the endpoint and both DNS settings on the VPC, then check that the name returns private addresses.
7. The endpoint’s security group doesn’t allow your clients. The interface endpoint has its own security group, and it has to allow inbound HTTPS from the subnets or security groups that call the service.
Fix: allow inbound 443 on the endpoint’s security group from your workloads.
It can’t reach the internet
8. The NAT gateway path is incomplete. A classic public NAT gateway must be in the Available state, sit in a public subnet whose route table sends internet traffic to an internet gateway, and the private subnet’s route table must send 0.0.0.0/0 to the NAT gateway. Security groups and network ACLs on both subnets have to allow the traffic. A private NAT gateway can’t reach the internet at all.
Fix: check each link in that chain. VPC Flow Logs show where packets are dropped.
9. Long idle connections drop. A NAT gateway closes a connection after 350 seconds without traffic and sends a reset. Database connections and long polls fail at random.
Fix: turn on TCP keepalive with an interval under 350 seconds, or keep the connection busy.
It works, but costs too much
10. S3 or DynamoDB traffic goes through the NAT gateway. Without a gateway endpoint, every GB to S3 or DynamoDB pays the NAT processing charge, even inside one Region. This is the most common NAT gateway surprise.
Fix: add a gateway endpoint for S3 (and DynamoDB, if you use it) and associate it with every private route table.
11. One NAT gateway serves every zone. Workloads in other zones send their traffic across zones to reach it, which adds cross-zone data charges, and if that zone has a problem, every zone loses its way out.
Fix: put a NAT gateway in each zone with workloads, with each zone’s private route table pointing at its own, or use a regional NAT gateway.
12. Chatty AWS API traffic goes through the NAT gateway. Pulling container images, shipping logs and calling a cluster’s public API endpoint all count as NAT traffic.
Fix: add interface endpoints for the busiest services, such as ECR and CloudWatch Logs, and use private endpoints where a service offers them, such as the EKS cluster endpoint.
How to check it
1. Read the subnet’s route table. Look for the pl- route to a vpce- target, and the 0.0.0.0/0 route to the NAT gateway. If this returns nothing, the subnet uses the main route table.
aws ec2 describe-route-tables \
--filters Name=association.subnet-id,Values=subnet-0abc1234
2. List the VPC’s endpoints and their policies.
aws ec2 describe-vpc-endpoints \
--filters Name=vpc-id,Values=vpc-0abc1234
3. Check DNS from the workload. For a service with an interface endpoint, the name should return private addresses from your VPC.
nslookup sqs.us-east-1.amazonaws.com
4. Find out what goes through the NAT gateway. CloudWatch has metrics for each NAT gateway, such as BytesOutToDestination. For the destinations, turn on VPC Flow Logs for the NAT gateway’s network interface and query them with Athena.
5. Find it on the bill. In Cost Explorer, group by usage type and look for NatGateway-Bytes. Turn on Cost Anomaly Detection so a jump reaches you in days, not at the end of the month.
6. Test again with a new connection. Adding a gateway endpoint changes routes and closes open TCP connections, so retry the request rather than waiting on an old one.
Checklist
- The workload’s subnet route table has a
pl-route to the S3 gateway endpoint, and DynamoDB if you use it. - Buckets and tables are in the same Region as the endpoint, and your code uses that Region.
- The endpoint policy allows the buckets you use.
- Bucket policies use
aws:SourceVpceoraws:SourceVpc, notaws:SourceIp, for traffic through the endpoint. - Security groups allow outbound 443 to the prefix list, and network ACLs allow the service’s ranges.
- Interface endpoints have private DNS on, and the VPC has DNS resolution and DNS hostnames on.
- The interface endpoint’s security group allows inbound 443 from your workloads.
- For internet access, the NAT gateway is Available, the path to the internet gateway is complete, and the private route table points
0.0.0.0/0at it. - Long-lived connections send keepalives more often than every 350 seconds.
- Each zone with workloads has its own NAT gateway, or you use a regional NAT gateway.
- Busy AWS services have interface endpoints.
- Cost Anomaly Detection is on, and you know your normal
NatGateway-Byteslevel.
From the field
Two teams have written publicly about finding this on their bill.
Geocodio: $907 in one day. Geocodio mirrors large datasets to S3 from EC2. A few days after they deployed a new S3 sync process, AWS Cost Anomaly Detection flagged a spike: 20,167 GB through the NAT gateway in a single day, $907.53 at $0.045 per GB, and more than $1,000 for the month so far. The instances and the bucket were in the same Region, but the traffic still went through the NAT gateway, which charges for every GB it processes. The fix was a gateway endpoint for S3, associated with their route tables in Terraform, and an audit of every VPC that talks to S3. AWS refunded the charge after they explained what happened. (Geocodio’s write-up)
ShipMonk: a monitoring chart that doubled the NAT bill. At ShipMonk, the NAT gateway cost for their development environments grew to about twice its normal level. The billing tool showed only a cost and a resource ID, which led to the NAT gateway in eu-west-1, and the increase started on the day a cost-reporting Helm chart was installed. VPC Flow Logs, stored in S3 and queried with Athena, showed the traffic was going to the EKS cluster’s public API endpoint, from around 100 environments with about 100 pods each. Enabling the cluster’s private endpoint kept that traffic inside the VPC, and NAT usage went back to its old level. Their note for anyone doing the same: allow every subnet and security group that calls the cluster in the cluster security group, or the calls time out. (ShipMonk’s write-up)
Neither team had anything misconfigured in the usual sense. The traffic took the default path, and the default path was the NAT gateway.
Keep going
Related guides:
- S3 Access Denied with an IAM Allow? 11 causes and how to find yours
- AWS bill higher than expected? 12 hidden costs and how to find them
- EC2 SSH connection timed out? 12 causes and how to find yours
- Short: AWS charges for every public IPv4 address, even idle ones
Shorts from this guide: Lambda in a VPC can't reach S3, S3 Access Denied after adding a VPC endpoint, send S3 traffic through a free endpoint, one NAT gateway for every zone.
Get the next one: new guides go out first on the AWS Cloud in a Minute newsletter, with a long video and Shorts on YouTube. I also run Azure Cloud in a Minute and Kubernetes in a Minute.
Sources
From AWS:
- Amazon VPC pricing (NAT gateway)
- AWS PrivateLink pricing (interface endpoints)
- NAT gateway pricing and how to reduce data processing charges
- Troubleshoot NAT gateways
- AWS NAT Gateway now supports regional availability
- Introducing Amazon VPC regional NAT gateway
- Gateway endpoints
- Gateway endpoints for Amazon S3
- Create an interface VPC endpoint
- Controlling access from VPC endpoints with bucket policies
- AWS global condition context keys (aws:SourceIp)
Field cases from Geocodio and ShipMonk, linked above.
Independent writer, not affiliated with or endorsed by Amazon Web Services.








Top comments (1)
Great checklist. One ECR gotcha to add under #12: image pulls need three paths, not two. The ecr.api and ecr.dkr interface endpoints cover the API and registry calls, but the layers themselves are downloaded from S3, so the subnet's route table also needs the S3 gateway endpoint. A private subnet with only the two interface endpoints and no NAT will authenticate fine and then fail on the layer download. And if you have narrowed the S3 endpoint policy (cause #3), it has to allow the regional ECR layer bucket too, which is easy to miss.
For the cost side on Fargate: the awslogs driver sends logs to CloudWatch Logs, so without a logs endpoint that traffic stays on the NAT gateway.