Skip to content

How do I allow the tasks in my Amazon ECS services to communicate with each other?

2 minute read
0

I want to allow the tasks in my Amazon Elastic Container Service (Amazon ECS) services to communicate with each other.

Short description

Use Amazon ECS Service Connect, service discovery, or Amazon Virtual Private Cloud (Amazon VPC) Lattice to allow your tasks to communicate with each other. It's a best practice to use Service Connect as it provides the Amazon ECS configuration for service discovery, connectivity, and traffic monitoring.

To determine the option that fits your architecture, see Interconnect Amazon ECS services.

Note: Service Connect isn't compatible with the host network mode. However, service discovery supports the A and SRV record types. Service Connect automatically adds or removes DNS records as tasks start or stop.

Resolution

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.

Use Service Connect

Use the Amazon ECS console or the AWS CLI to configure Service Connect. Then, use the endpoint URL to connect with other services within the same namespace.

Use service discovery

Prerequisites: Make sure that you meet the service discovery requirements.

Configure service discovery. Then, use the YourServiceDiscoveryServiceName.YourServiceDiscoveryNamespace format to query DNS records for a discovery service within Amazon VPC.

Use Amazon VPC Lattice

Use the Amazon ECS console or the AWS CLI to configure Amazon VPC Lattice. Then, use target groups to connect with other services or applications. You can connect to Amazon Elastic Compute Cloud (Amazon EC2) instances, IP addresses, AWS Lambda functions, and Application Load Balancers.

AWS OFFICIALUpdated a month ago
3 Comments

"Important: After you have configured service discovery, use the YourServiceDiscoveryServiceName.YourServiceDiscoveryNamespace format to query DNS records for a service discovery service within your Amazon Virtual Private Cloud (Amazon VPC)." - this doesn't seem to work and gives connection refused error.

replied 3 years ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

AWS
EXPERT

replied 3 years ago

This article was reviewed and updated on 2026-08-10.

EXPERT

replied a month ago