FREE TOOL

AWS VPC Connectivity Troubleshooter

Find why a Lambda function, Fargate task or EC2 instance cannot reach the internet, S3 or ECR, and fix ResourceInitializationError and VPC timeouts.

  • Your data never leaves your browser: everything is calculated by JavaScript on this page, not on a server.
  • Nothing you enter is uploaded, processed on a server or stored. Check it in your browser's developer tools (Network tab).
  • Once the page has loaded, the tool works without an internet connection.

Error message

From the ECS console, the Lambda logs, the AWS CLI, an SDK or your SSH client. Optional - or set up the path below by hand.

What cannot connect

Filled in from the error where it says.

FROM
TO

Its subnet

Where the subnet's route table sends 0.0.0.0/0. Not sure? The route table tells: aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=subnet-...

See result ↓

What the path needs

ECS TASK ON FARGATE

Without a NAT gateway, Amazon ECR (image pull) is reachable only through VPC endpoints.

  1. The VPC has these endpoints: com.amazonaws.us-east-1.ecr.api (interface), com.amazonaws.us-east-1.ecr.dkr (interface), com.amazonaws.us-east-1.s3 (gateway), each available. aws ec2 describe-vpc-endpoints --filters Name=vpc-id,Values=vpc-0123456789abcdef0 --query "VpcEndpoints[].[ServiceName,VpcEndpointType,State,PrivateDnsEnabled]"
  2. Missing com.amazonaws.us-east-1.ecr.api? Create it. aws ec2 create-vpc-endpoint --vpc-endpoint-type Interface --vpc-id vpc-0123456789abcdef0 --service-name com.amazonaws.us-east-1.ecr.api --subnet-ids subnet-0123456789abcdef0 --security-group-ids sg-0123456789abcdef0 --private-dns-enabled
  3. Missing com.amazonaws.us-east-1.ecr.dkr? Create it. aws ec2 create-vpc-endpoint --vpc-endpoint-type Interface --vpc-id vpc-0123456789abcdef0 --service-name com.amazonaws.us-east-1.ecr.dkr --subnet-ids subnet-0123456789abcdef0 --security-group-ids sg-0123456789abcdef0 --private-dns-enabled
  4. Missing com.amazonaws.us-east-1.s3? Create it - a gateway endpoint is free. aws ec2 create-vpc-endpoint --vpc-id vpc-0123456789abcdef0 --service-name com.amazonaws.us-east-1.s3 --route-table-ids rtb-0123456789abcdef0
  5. A gateway endpoint works only for the route tables it is associated with: the subnet's route table shows a route to a prefix list (pl-...) with the endpoint as its target. It reaches only resources in the VPC's own Region. aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=subnet-0123456789abcdef0 --query "RouteTables[].Routes[]"
  6. Interface endpoints have private DNS enabled, and the VPC has DNS resolution and DNS hostnames turned on. Without them the service's usual name still resolves to public IP addresses, and the calls time out. From inside the VPC, the name must resolve to private addresses. aws ec2 describe-vpc-attribute --vpc-id vpc-0123456789abcdef0 --attribute enableDnsHostnames
  7. The interface endpoints' security group allows inbound 443 from the resource's security group (or the VPC's CIDR block). aws ec2 describe-security-groups --group-ids sg-0123456789abcdef0 --query "SecurityGroups[].IpPermissions"
  8. The task also calls the other services its task definition uses: com.amazonaws.us-east-1.logs for the awslogs log driver, secretsmanager or ssm for secrets. Each needs its own interface endpoint.
  9. The resource's security group allows outbound HTTPS (443), or the port the destination uses. New security groups allow all outbound traffic until the rule is removed. aws ec2 describe-security-groups --group-ids sg-0123456789abcdef0 --query "SecurityGroups[].IpPermissionsEgress"
  10. The call fails with AccessDenied instead of a timeout? Then the network works, and IAM says no: the role's policy, a resource policy (bucket, key, secret), or an endpoint policy.

IDs such as vpc-0123456789abcdef0 are placeholders: replace them with yours before running a command.

NAT gateways, VPC endpoints and security groups are core AWS Solutions Architect Associate topicsTry free SAA-C03 practice questions with answers and explanations.SAA-C03 questions →

How traffic leaves a VPC

Every subnet has a route table, and the route for 0.0.0.0/0 decides where traffic to anything outside the VPC goes. That route, not the subnet's name, is what makes a subnet public or private:

0.0.0.0/0 goes toThe subnet isWhat reaches the internet and AWS services
An internet gateway (igw-)PublicOnly resources with a public IP address: EC2 instances with a public IPv4 or Elastic IP, Fargate tasks with assignPublicIp enabled. Never a Lambda function.
A NAT gateway (nat-)PrivateEverything in the subnet, outbound only. The NAT gateway itself sits in a public subnet.
NothingPrivate (isolated)Only the VPC itself and the AWS services it has VPC endpoints for.

The trap most people fall into: a Lambda function connected to a VPC gets network interfaces with private IP addresses only. Put it in a public subnet and its calls to the internet or to AWS APIs hang until the function times out. A function in a VPC needs private subnets with a NAT gateway, or VPC endpoints - or, if it needs nothing inside the VPC, no VPC at all: outside a VPC, Lambda reaches the internet by default.

Gateway and interface VPC endpoints

VPC endpoints let a private subnet call AWS services without a NAT gateway, and keep the traffic off the internet. There are two kinds:

Gateway endpointInterface endpoint (AWS PrivateLink)
ServicesAmazon S3 and DynamoDB onlyMost AWS services, S3 included
How it worksA route to the service's prefix list in the route tables you pickNetwork interfaces with private IPs in your subnets; private DNS points the service's name at them
CostFreePer hour per Availability Zone, and per GB
Security groupsThe resource's outbound rulesThe endpoint's own security group must allow inbound 443
ReachThe VPC's own Region, from inside the VPCAlso from peered VPCs and on-premises networks

Some services need several endpoints. Pulling an image from Amazon ECR takes ecr.api, ecr.dkr and the S3 gateway endpoint, because image layers are stored in S3; a Fargate task also needs logs for the awslogs driver, and secretsmanager or ssm for the secrets in its task definition. Session Manager needs ssm, ssmmessages and ec2messages. Even with a NAT gateway, the S3 and DynamoDB gateway endpoints are worth adding: they are free, and that traffic stops paying the NAT gateway's per-GB processing charge.

Connecting to an EC2 instance

MethodPublic IPInbound ruleAlso needs
SSH or RDP from your computerYes22 or 3389 from your IPThe key pair, a route to an internet gateway
EC2 Instance Connect (console)Yes22 from the Region's ec2-instance-connect prefix listEC2 Instance Connect on the AMI
EC2 Instance Connect EndpointNo22 or 3389 from the endpoint's security groupAn endpoint in the VPC
Session ManagerNoNoneSSM Agent, the AmazonSSMManagedInstanceCore role, outbound 443 to Systems Manager

A NAT gateway does not make a private instance reachable: it carries outbound connections only. To get into a private instance, use Session Manager or an EC2 Instance Connect Endpoint rather than opening port 22.

VPC connectivity errors and what they mean

ErrorMost common cause
ResourceInitializationError: unable to pull secrets or registry authFargate task without a route to ECR or Secrets Manager: no public IP, NAT gateway or endpoints
CannotPullContainerError ... i/o timeoutThe same, or ECR endpoints without the S3 gateway endpoint
Task timed out after N secondsLambda in a VPC calling out without a NAT gateway or endpoint
Connect timeout on endpoint URL, connect ETIMEDOUT, dial tcp ... i/o timeoutNo route to the service, or an interface endpoint without private DNS
The provided execution role does not have permissions to call CreateNetworkInterface on EC2The function's role lacks AWSLambdaVPCAccessExecutionRole
TargetNotConnectedSSM Agent offline: no instance role, or no way out to Systems Manager
ssh: connect to host ... port 22: Connection timed outSecurity group, no public IP, or no route to an internet gateway
Connection refusedThe instance was reached, but nothing listens on the port
Permission denied (publickey)Wrong user name or key - the network works

One rule sorts most of them: a timeout means the network - route, NAT gateway, endpoint, security group or network ACL. An AccessDenied means the network works and IAM says no. For a path you cannot work out, the VPC Reachability Analyzer traces it hop by hop and names the component that blocks it.

Frequently asked questions

Why can't my Lambda function in a public subnet reach the internet?

Lambda's network interfaces in a VPC never get public IP addresses, and an internet gateway only serves resources that have one. Move the function to private subnets that route to a NAT gateway, use VPC endpoints for the AWS services it calls, or take it out of the VPC.

Do I need a NAT gateway to access S3 from a private subnet?

No. An S3 gateway endpoint gives private subnets access to buckets in the same Region, and it is free. The same goes for DynamoDB. Buckets in other Regions still need a NAT gateway or an interface endpoint in their Region.

What does ResourceInitializationError mean on ECS Fargate?

The task could not fetch what it needs before starting - the ECR login, the image, or secrets - usually because its subnet has no way out: a public subnet without a public IP, or a private subnet without a NAT gateway or the ECR, S3 and Secrets Manager endpoints. If the message says AccessDenied, it is the task execution role instead.

Is it safe to paste an error message here?

Yes. Everything runs in your browser: nothing you enter is uploaded, processed on a server or stored. The page only counts which error it recognized and which path was looked at, never the text.

References

Enable internet access for VPC-connected Lambda functions
Gateway endpoints
Amazon ECR interface VPC endpoints
Amazon ECS interface VPC endpoints
Improve EC2 instance security with VPC endpoints for Systems Manager
Connect to an instance using EC2 Instance Connect Endpoint