# AWS EC2: Connection timed out

> Fix SSH to EC2 failing with Connection timed out. Check the security group, route table, network ACL, public IP and firewalls in order, with commands to test each.

Canonical: https://scaplet.com/errors/cdn/aws-ec2-connection-timed-out

Guide Error · CDN and hosting errors

Fix SSH to EC2 failing with Connection timed out. Check the security group, route table, network ACL, public IP and firewalls in order, with commands to test each.

4 min

read

2

sources

Oct 31, 2026

updated

Scaplet Editorial Team

author

In one line

An EC2 connection timed out means your packets got no answer at all: something between you and the instance dropped them silently. AWS's checklist, in order: a security group rule allowing your public IP on port 22, a route to an internet gateway, a network ACL that allows port 22 in and ephemeral ports 1024-65535 out, a public IPv4 address, and no local firewall in the way.

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Faws-ec2-connection-timed-out%20(%22AWS%20EC2%3A%20Connection%20timed%20out%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Faws-ec2-connection-timed-out%20(%22AWS%20EC2%3A%20Connection%20timed%20out%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Faws-ec2-connection-timed-out%20(%22AWS%20EC2%3A%20Connection%20timed%20out%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Faws-ec2-connection-timed-out%20(%22AWS%20EC2%3A%20Connection%20timed%20out%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

## At a glance

4 facts from the sources below

Network error: Connection timed out

Symptom

22 for SSH

Port to open

Ephemeral ports 1024-65535

NACL outbound

0.0.0.0/0 to the internet gateway

Route needed

_01_Read the message to pick the checklist

## Timed out is not refused

The wording matters. A timeout means no reply came back, which points to a network layer dropping traffic. A refusal or a login error means traffic arrived and something answered, so those are SSH or key problems and belong to a different checklist. AWS lists the timeout strings as `Network error: Connection timed out` and `Error connecting to [instance], reason: -> Connection timed out: connect`.

Message

### Connection timed out

Meaning

No answer: dropped by a security group, route, NACL or firewall, or no public address

Go to

This page

Message

### Connection refused

Meaning

Reached the host; nothing is listening or something rejected it

Go to

Check sshd is running on the instance

Message

### Permission denied (publickey)

Meaning

Reached sshd; key or username rejected

Go to

Check the key pair and the AMI's default username

The five places a packet can die before it reaches sshd

```
you --> [your firewall] --> internet --> [route table + internet gateway] --> [network ACL on subnet] --> [security group on instance] --> sshd :22
```

_02_Fix it on your stack

## See the timeout from your side

Confirm the symptom with a tool that reports it plainly. This test was run against 192.0.2.1, an address reserved for documentation that never answers, so it times out the same way a silently dropped EC2 connection does. Swap in your instance's public IPv4 address.

Check port 22 with a 5 second limit (macOS nc shown; Linux nc uses -w 5)
Check port 22 with a 5 second limit (macOS nc shown; Linux nc uses -w 5)

```
nc -vz -G 5 192.0.2.1 22 # observed on macOS: nc: connectx to 192.0.2.1 port 22 (tcp) failed: Operation timed out
```

Same test through ssh: ConnectTimeout stops the long wait
Same test through ssh: ConnectTimeout stops the long wait

```
ssh -o ConnectTimeout=5 -o BatchMode=yes ubuntu@192.0.2.1 # observed: ssh: connect to host 192.0.2.1 port 22: Operation timed out
```

Find the public address your rule must allow
Find the public address your rule must allow

```
curl -s https://checkip.amazonaws.com # prints the public IPv4 address your traffic leaves from
```

_03_Explained

## Work the checklist in order

1. 01

Security group

On the instance's **Security** tab, under **Inbound rules**, look for a rule allowing your computer's public IPv4 address to port 22. AWS notes the default security group for a VPC does not allow incoming SSH, while the one created by the launch wizard does.
2. 02

Is the source stale

If the **Source** is a single IP and your address is not static, a new one is assigned after a restart, a corporate network or an ISP change, and the rule no longer matches. Use the range of addresses your client computers use.
3. 03

Route table

Open the subnet's **Route table** tab. You need a route with `0.0.0.0/0` as destination and the VPC's internet gateway as target. For IPv6, a route for `::/0` to the same gateway. Also confirm an internet gateway is attached to the VPC.
4. 04

Network ACL

The subnet's ACL must allow [inbound](/glossary/inbound-marketing) SSH from your IP on port 22 and outbound traffic to the ephemeral ports 1024-65535.
5. 05

Public address

The instance needs a public IPv4 address. If it has none, associate an Elastic IP.
6. 06

Firewalls on your side

On a corporate network, ask whether the firewall allows port 22 in and out. Check the local firewall on your own machine too.
7. 07

Load on the instance

AWS also lists an overloaded server: check CPU load in CloudWatch metrics and instance status, and scale or resize if it is steady.

Also confirm the instance is in the `running` state and has passed its status checks. A just-launched instance can take a few minutes before it accepts connections.

_04_Your call

## Change the rules from the CLI

These commands need your own account and are not copied from the AWS troubleshooting page, which uses the console. Use `--dry-run` first: EC2 commands accept it and report whether you have permission without changing anything.

If this fits

### Open port 22 to one address when

- You connect from a fixed office or home IP
- You can update the rule when the address changes

Or

### Use a range or another method when

- Your ISP or office address changes often
- You can use Session Manager or EC2 Instance Connect instead, both listed in AWS's prerequisites

Add an SSH rule for one address (replace the group ID and address)

```
aws ec2 authorize-security-group-ingress \ --group-id sg-0123456789abcdef0 \ --protocol tcp --port 22 \ --cidr 203.0.113.25/32 \ --dry-run
```

Add a default route to an internet gateway (replace both IDs)

```
aws ec2 create-route \ --route-table-id rtb-0123456789abcdef0 \ --destination-cidr-block 0.0.0.0/0 \ --gateway-id igw-0123456789abcdef0 \ --dry-run
```

_05_Explained

## If the same timeout hits your website

SSH timing out does not affect crawlers, but a missing rule on ports 80 or 443 produces the same silence for visitors. Google treats network timeouts, connection resets and DNS errors similarly to `5xx` server errors, and crawling immediately starts slowing down. Indexed URLs that stay unreachable can be removed from the index within days. Google's suggested checks include overly broad firewall rules, so review security group and ACL rules for web ports as carefully as for SSH. Related reading: timeout errors and [Lambda timeouts](/errors/cdn/lambda-timeout).

Questions

## Asked a lot.

4 questions people ask next, answered from the sources on this page.

_01_ Why does EC2 say connection timed out but the instance is running?

Running only means the instance is up. A timeout means traffic is dropped before it reaches sshd, most often by a security group with no rule for your current IP, a missing internet gateway route, a network ACL, or a firewall on your network.

_02_ Which ports does a network ACL need for SSH?

Inbound port 22 from your IP, and outbound traffic to the ephemeral ports 1024-65535. AWS says ACLs must allow both.

_03_ Why did SSH work yesterday and time out today?

If the security group rule names a single IP and your address is not static, it changes after a restart or when your ISP reassigns it, so the rule no longer includes you.

_04_ Do I need a public IP to connect over SSH from the internet?

Yes, AWS lists checking that the instance has a public IPv4 address. If it has none, you can associate an Elastic IP address.

Sources · 2

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- amazon.com
- google.com

1. 01 [Amazon EC2 docs: Troubleshoot issues connecting to your Amazon EC2 Linux instance](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html) docs.aws.amazon.com · checked 2026-11-01
2. 02 [Debugging DNS and network errors for Google crawlers](https://developers.google.com/crawling/docs/troubleshooting/dns-network-errors) developers.google.com · checked 2026-11-01

## Keep learning

[All errors](/errors)

[Learn AWS 502 Bad Gateway CDN and hosting errors](/errors/cdn/aws-502-bad-gateway) [Related HTTP status codes Crawling and indexing](/glossary/http-status-codes) [Read next AWS Lambda timeout CDN and hosting errors](/errors/cdn/lambda-timeout) [Do Run a free site audit Free, about two minutes](/site-audit)

More AWS errors
[AWS 502 Bad Gateway](/errors/cdn/aws-502-bad-gateway) [AWS Lambda 502 Bad Gateway](/errors/cdn/aws-lambda-502)

More in CDN and hosting errors
[Vercel 500: Internal Server Error](/errors/cdn/vercel-500) [Vercel build failed](/errors/cdn/vercel-build-failed) [Vercel domain not working](/errors/cdn/vercel-domain-not-working) [Vercel FUNCTION_INVOCATION_TIMEOUT](/errors/cdn/vercel-function-invocation-timeout) [Vercel: too many redirects](/errors/cdn/vercel-too-many-redirects) [Akamai reference number](/errors/cdn/akamai-reference-number) [ALB 503 Service Unavailable](/errors/cdn/alb-503) [ALB 504 Gateway Timeout](/errors/cdn/alb-504-gateway-timeout) [API Gateway 403 Forbidden](/errors/cdn/api-gateway-403-forbidden) [API Gateway 504 Gateway Timeout](/errors/cdn/api-gateway-504) [AWS 502 Bad Gateway](/errors/cdn/aws-502-bad-gateway) [AWS Amplify 404 Not Found](/errors/cdn/amplify-404) [AWS EC2: Connection timed out](/errors/cdn/aws-ec2-connection-timed-out) [AWS Lambda 502 Bad Gateway](/errors/cdn/aws-lambda-502) [AWS Lambda timeout](/errors/cdn/lambda-timeout) [Azure Front Door 502](/errors/cdn/azure-front-door-502) [Cloud Run 503 error](/errors/cdn/cloud-run-503) [Cloudflare 504 Gateway Timeout](/errors/cdn/cloudflare-504) [Cloudflare Pages 404 Not Found](/errors/cdn/cloudflare-pages-404) [Cloudflare too many redirects (ERR_TOO_MANY_REDIRECTS)](/errors/cdn/cloudflare-too-many-redirects) [Cloudflare verify you are human loop](/errors/cdn/cloudflare-verify-you-are-human-loop) [CloudFront 400: Bad Request](/errors/cdn/cloudfront-400) [CloudFront 404 Not Found](/errors/cdn/cloudfront-404) [CloudFront 503: Service Unavailable](/errors/cdn/cloudfront-503)

Terms on this page
[Inbound marketing](/glossary/inbound-marketing)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
