How can I resolve the error I get when my Amazon EC2 instances fail to communicate with Elastic Beanstalk?

Last updated: 2021-03-04

When I try to create an AWS Elastic Beanstalk environment, I get the following error: "The EC2 instances failed to communicate with AWS Elastic Beanstalk, either because of configuration problems with the VPC or a failed EC2 instance. Check your VPC configuration and try launching the environment again."

Short description

You receive this error if your Amazon Elastic Compute Cloud (Amazon EC2) instances aren't configured to initiate outbound connections to Elastic Beanstalk and other service endpoints. Your instances must have access to these endpoints through either a public subnet, private subnet, or Amazon Virtual Private Cloud (Amazon VPC) endpoints.

Resolution

  1. Verify that the network ACL associated with your subnets allows outbound connections to the internet. For example: 0.0.0.0/0
  2. If you select a custom Amazon VPC when you created your Elastic Beanstalk environment, choose the appropriate subnets for instance and load balancer visibility.
  3. If your EC2 instances are in a public subnet, verify that the route table has a route to the internet through an internet gateway. For example: 0.0.0.0/0
  4. If your EC2 instances are in a private subnet, verify that the route table associated with the NAT gateway or the NAT instance has a route to the internet. For example: 0.0.0.0/0
    Note: Your NAT gateway or NAT instance must be in a public subnet to communicate with the internet.
  5. Verify that the attributes enableDnsHostnames and enableDnsSupport are enabled in the VPC where you launched your Elastic Beanstalk environment.
  6. If your Elastic Beanstalk environment is using VPC endpoints, set up the following endpoints to launch your environment properly:
    Amazon Simple Queue Service (Amazon SQS)
    AWS CloudFormation
    Elastic Beanstalk (com.amazonaws.your-region.elasticbeanstalk)
    Elastic Beanstalk health (elasticbeanstalk-health.your-region.amazonaws.com)
    Amazon Simple Storage Service (Amazon S3)
    Note: If your environment must interact with other AWS services, create the appropriate VPC endpoints for those services.