Free auditStart free
GuideError · CDN and hosting errors

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.

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 withChatGPTClaudePerplexityGoogleAI Mode

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
02Fix 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)
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
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
curl -s https://checkip.amazonaws.com
# prints the public IPv4 address your traffic leaves from
03Explained

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 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.

04Your 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
05Explained

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.

Questions

Asked a lot.

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

01Why 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.

02Which 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.

03Why 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.

04Do 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. 01Amazon EC2 docs: Troubleshoot issues connecting to your Amazon EC2 Linux instancedocs.aws.amazon.com · checked 2026-11-01
  2. 02Debugging DNS and network errors for Google crawlersdevelopers.google.com · checked 2026-11-01
Free · 2 minutes

Tools point. Agencies advise. This one ships.

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

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane