CloudConsole

Could not connect to the endpoint URL

Updated 17 November 2026 · How we write and check guides

Short answer

The AWS CLI or SDK built a service URL but couldn't open a TCP or TLS connection to it, so the request never reached AWS. The usual causes are a misspelt or wrong Region (which produces a hostname that doesn't exist), a service that isn't offered in that Region, or a machine with no route out: a private subnet without a NAT gateway or VPC endpoint, a firewall or proxy, or a local emulator that isn't running.

Most common causes, in 4 steps: 1. An Availability Zone such as eu-west-2a , a typo, or a display name; 2. A real Region…
The diagnosis and fix steps from this page, in the order to try them; commands and details are below.

What the error tells you

Could not connect to the endpoint URL: "https://ec2.eu-west-2a.amazonaws.com/"

This is a client-side connection failure (botocore's EndpointConnectionError), not an AWS error code. No credentials were checked and nothing was logged in CloudTrail. Read the hostname in the message first: it shows exactly which Region and service the client was aiming at, and most of the time that alone gives the answer.

Most common causes

What you see in the URLCause
An Availability Zone such as eu-west-2a, a typo, or a display nameThe Region is set to something that isn't a Region code. Use eu-west-2, not eu-west-2a or London.
A real Region and a service that isn't thereNot every service runs in every Region. Check the service's endpoints page.
A correct hostnameNetwork: no internet route, blocked port 443, a proxy that needs HTTPS_PROXY, or DNS that can't resolve AWS names.
http://localhost:4566 or another custom hostAn --endpoint-url or AWS_ENDPOINT_URL setting points at an emulator or proxy that isn't listening.

How to fix it

  1. Check the Region the CLI resolved.
    aws configure list
    aws configure get region --profile prod
    env | grep -E 'AWS_(DEFAULT_)?REGION|AWS_ENDPOINT_URL'
    Environment variables beat the config file, so a stale AWS_REGION in your shell or CI job overrides the profile.
  2. Test the network path directly.
    nslookup sts.eu-west-2.amazonaws.com
    curl -sv https://sts.eu-west-2.amazonaws.com/ -o /dev/null 2>&1 | grep -E 'Connected|SSL|timed out'
    If DNS fails or the connection times out, the problem is the network, not AWS.
  3. On EC2, ECS or Lambda in a VPC, a private subnet needs a route to a NAT gateway, or an interface VPC endpoint for that service (with private DNS enabled) or a gateway endpoint for S3 and DynamoDB. Check the subnet's route table and the endpoint's security group, which must allow inbound 443 from your workload.
  4. Behind a corporate proxy, set HTTPS_PROXY and, for internal hosts, NO_PROXY. Add --debug to see which proxy and URL the CLI is using.
  5. With LocalStack or another emulator, confirm the container is running and the port is published; inside Docker Compose, use the service name instead of localhost.

Gotchas

  • ECR in a private subnet needs both the ecr.api and ecr.dkr interface endpoints plus the S3 gateway endpoint, because image layers come from S3. Missing one gives this error from api.ecr.<region>.amazonaws.com or a pull timeout.
  • Global services such as IAM sign requests to a fixed endpoint; a Region typo there may not show up until you call a Regional service.
  • Timeouts that look like this: Connect timeout on endpoint URL is the same family of problem (no route), while Read timeout on endpoint URL means the connection worked but the response was too slow.

Questions

Why does the AWS CLI say it could not connect to the endpoint URL?

The client couldn't open a connection to the hostname it built from the service and Region. Check the Region spelling first, then DNS and network access to port 443.

How do I fix could not connect to the endpoint URL localhost 4566?

Port 4566 is LocalStack's default. Start the LocalStack container, make sure the port is published, and from another container use the Compose service name rather than localhost.

Does a VPC endpoint fix this error in a private subnet?

Yes, if the subnet has no NAT route. Create an interface endpoint for the service with private DNS enabled, or a gateway endpoint for S3 or DynamoDB, and allow 443 in the endpoint's security group.

CloudConsole home screen showing what needs attention on a phone, for following up on Could not connect to the endpoint URL…
When this happens away from your desk

This error usually turns up in a failing deploy job or a container that can't reach AWS. CloudConsole, a phone app for AWS, is being built to show alarms, logs and resources on your phone, which helps you see which workload is affected while you're away from a terminal.

Did it start after a deploy? What changed? on the app’s alarm screen lists the deploys and configuration changes from the hour before the alarm fired.

About the app → · Download on the App Store

Sources