Can’t SSH into Your EC2 Instance Even Though It’s Running? Here’s What You Should Check

Deploying projects on AWS EC2 instances can be exciting — until something goes wrong. One of the most frustrating issues I recently faced was not being able to SSH into an EC2 instance that previously worked perfectly. The instance was marked as “running” on the AWS Console, yet SSH connections failed completely.

If you’ve ever been in a similar situation, this blog post will walk you through what I experienced and what you should check when your EC2 instance is up but SSH isn’t working.

The Problem: EC2 Running, SSH Not Working

Everything was working fine I had access, I was developing, and then suddenly, SSH stopped responding.

Here’s what I knew:

  • The instance status was still showing as running on the AWS Console.

  • No obvious alerts or errors were displayed.

  • But when I tried to SSH:

 
ssh -i my-key.pem ec2-user@ec2-xx-xx-xx-xx.compute-1.amazonaws.com

It just hung or timed out.

What I Checked (and You Should Too)

1. Security Group Inbound Rules

The first thing to check is whether port 22 (SSH) is open:

  • Go to EC2 → Instances → Select your instance

  • Scroll to Security Groups

  • Ensure Inbound Rules have:

    • Type: SSH

    • Protocol: TCP

    • Port Range: 22

    • Source: Anywhere (0.0.0.0/0) or your IP (for security)

Even if the rules were working before, double-check — sometimes IP restrictions or accidental changes cause access issues.

2. Elastic IP or Public IP

If your instance doesn’t have a static Elastic IP, it gets a new public IP every time it’s stopped and started.

So:

  • Confirm you’re SSHing into the correct current IP address

  • Update your SSH command with the latest IP from the AWS Console

3. Key File (PEM) and Username

Double-check:

  • The PEM file name and path

  • The correct user (e.g., ec2-user for Amazon Linux, ubuntu for Ubuntu)

Wrong key or wrong user = no access.

4. Instance Storage/Memory Issues

Sometimes, if your instance runs out of memory or disk, the OS may become unresponsive — SSH included — even though AWS shows it as “running.”

In my case, I realized the instance was low on memory and had likely crashed at the OS level, but AWS still marked it as active.

5. Try EC2 Instance Connect (Browser-Based SSH)

AWS provides EC2 Instance Connect, a browser-based SSH tool:

  • Go to EC2 → Select Instance → Click Connect

  • Try logging in with EC2 Instance Connect (doesn’t need your PEM file)

If this also fails, it confirms the instance is non-responsive internally.

What I Did Next

After confirming my SSH key and IP were correct, and security rules were in place, I tried EC2 Instance Connect. No luck. I still couldn’t access the instance.

At that point, I suspected a low memory crash or filesystem corruption. Since there was no way to SSH in or repair it from the outside, I:

  1. Created a snapshot of the volume

  2. Launched a new EC2 instance

  3. Attached the old volume to the new instance as a secondary disk

  4. Mounted it and copied over my project files and configurations

  5. Set up my environment again on the new instance

It took time, but it worked.

Real Tip: Set Up Monitoring and Backups

To avoid future surprises:

  • Enable CloudWatch monitoring for memory and disk

  • Set up automatic daily snapshots

  • Use Elastic IP to avoid IP changes

Final Thoughts

When you can’t SSH into your EC2 instance, but it appears to be running:

  • Don’t panic.

  • Check your security group, IP address, and key file.

  • Try browser-based EC2 Instance Connect.

  • If all else fails, recover your data using snapshots and move to a new instance.

Related reads:

Other Topics:

External resources:

Leave a Comment

Your email address will not be published. Required fields are marked *