Why did my EC2 instance reboot or restart itself?
Last updated: 2020-06-25
Why did my Amazon Elastic Compute Cloud (Amazon EC2) instance reboot or restart unexpectedly?
Although unexpected reboots or restarts are rare, there are several reasons this might occur. The following are the most common reasons:
- The instance failed one or both of its status checks.
- The underlying hardware hosting your instance was faulty and Amazon EC2 restarted the instance to move it to new, healthy hardware.
- Scheduled maintenance occurred on your instance that required a reboot.
- A user or application inside your server rebooted the instance.
There are several actions you can take to determine why your instance rebooted:
View status checks
View the instance's status checks from the console or using the AWS Command Line Interface (AWS CLI). If a status check failure is indicated, see Why is my EC2 Linux instance unreachable and failing one or both of its status checks?
Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.
View system logs
If the instance didn't fail a status check, the instance might have rebooted due to operating system-level issues. Review the system logs to determine what error occurred. The system logs are located at /var/log/messages or /var/log/syslog depending on your OS distribution.
View reboot history
Use the following commands to determine if a user or an application inside the server initiated the reboot:
# grep reboot /home/*/.bash_history<br># grep reboot /root/.bash_history<br># history | grep -i reboot<br># history | grep -i init<br># last reboot
View AWS CloudTrail Events history
Instance reboots initiated from the Amazon EC2 console or through the AWS CLI appear in CloudTrail Events history. To view these events:
- Open the AWS CloudTrail console.
- Choose Event history.
- Select Event name from the filter drop down and then enter RebootInstances.
Note: You can create an Amazon CloudWatch alarm that automatically recovers instances experiencing underlying hardware issues resulting in reboot. For information on how to set up the CloudWatch alarm, see Recover your instance.