Can not connect to EC2 instance used with EBS.

0

I'm writing a web application and hosting on EBS.

I also have some additional storage which I attached to the related EC2 instance.

That all was working fine. While editing a file with vi on my attached storage (this was not a "system" file of any kind) the instance stopped responding. My web app hosted on the instance is also not responding.

When I select my EC2 instance, and then "Connect", using EC2 Instance Connect tab, I can no longer connect. This was previously working. The instance was created about10 days ago.

I'm not very savvy with the whole AWS thing. I only know it's been working fine and now it's not. It's like it crashed. I saw where I can reboot the instance but there was some scary warning there about auto-scaling being on, so I didn't proceed with that. Note, I did create a user account to allow me to ssh to the instance (which was also working, but now is not). I can not ping the instance.

Update: I tried rebooting the instance and after about 30 minutes it started working again.

asked 5 months ago114 views
2 Answers
1
Accepted Answer
  1. Check Instance Status in the AWS Console: Go to the EC2 Dashboard in the AWS Management Console. Look at the Instance State and Status Checks. If the status checks show any failures, this indicates an issue with the instance.
  2. Review Logs and Metrics: In the Monitoring tab of the EC2 instance, check for any unusual CPU, memory, or network activity that might indicate why the instance is unresponsive. Review CloudWatch Logs if they are configured, as they can provide more details on what might have gone wrong.
  3. Stop and Start the Instance: If the instance is unresponsive and you cannot connect to it, try stopping and then starting the instance. This will move it to a new host and might resolve the issue. Note: Stopping and starting the instance will change the public IP address (unless you have an Elastic IP associated with it). Auto-scaling shouldn't be an issue unless your instance is part of an Auto Scaling Group, which might automatically terminate and replace instances. Since you mentioned a warning about auto-scaling, ensure that stopping and starting the instance will not cause it to be replaced.
  4. Detach and Re-Attach the EBS Volume: If the instance is still unresponsive after restarting, consider detaching the EBS volume (the one you were editing) from the instance and then trying to reconnect. If you can reconnect after detaching the volume, the issue may be related to the EBS volume. You can try re-attaching it to see if the issue persists.
  5. Check Security Group and Network ACLs: Ensure that the Security Group associated with the instance allows SSH (port 22) and HTTP/HTTPS (ports 80/443) traffic. Verify that the Network ACLs for the subnet where the instance is located are not blocking incoming or outgoing traffic.
  6. Connect via SSM (Systems Manager) Session Manager: If you have AWS Systems Manager (SSM) Agent installed and configured on your instance, you can try connecting to it via Session Manager. This can be useful if SSH or EC2 Instance Connect isn’t working.
  7. Reboot the Instance: If all else fails, consider rebooting the instance. This might resolve transient issues, but be aware that if there's an underlying issue (e.g., disk corruption or a kernel panic), it may persist after reboot.
  8. Create a Snapshot of the EBS Volume: Before making any significant changes, you might want to create a snapshot of your EBS volumes for backup purposes.
  9. Review Instance System Logs: If you can connect via SSH or SSM, check the system logs (/var/log/messages or /var/log/syslog) to see if there are any errors or warnings that might indicate what went wrong.
profile pictureAWS
EXPERT
answered 5 months ago
profile picture
EXPERT
reviewed 5 months ago
profile picture
EXPERT
reviewed 5 months ago
profile pictureAWS
EXPERT
reviewed 5 months ago
  • About 30 minutes after the reboot (step 7) - it started working again.

1

Hello.

Is it possible to connect to EC2 with Systems Manager Session Manager instead of SSH?
Session Manager requires an IAM role attached to EC2, but I think you can try it as a connection method other than SSH.
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-prerequisites.html

By the way, can you check the EC2 system log?
Depending on the instance type you are using with EC2, you may not be able to view it, but if you can check the system log, please check to see if any errors are output.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/troubleshoot-unreachable-instance.html#instance-console-console-output

You should also be able to take a snapshot of your EC2 and create another EC2 from the snapshot to troubleshoot.
https://docs.aws.amazon.com/prescriptive-guidance/latest/backup-recovery/restore.html

profile picture
EXPERT
answered 5 months ago
profile picture
EXPERT
reviewed 5 months ago
  • I can download the system log. I think what I'm seeing is my reboot. I don't see anything that looks like an error, but there are entries like this, [ 36.551149] zram_generator::config[1884]: zram0: system has too much memory (904MB), limit is 800MB, ignoring. [ 36.870411] zram_generator::config[1912]: zram0: system has too much memory (904MB), limit is 800MB, ignoring. [ 37.167638] zram_generator::config[1940]: zram0: system has too much memory (904MB), limit is 800MB, ignoring.

  • From the message perspective, it looks like it's stuck due to lack of memory. Therefore, if the problem occurs again, please try taking measures such as increasing the instance type to another level or creating a swap area. https://repost.aws/knowledge-center/ec2-memory-swap-file

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions