I want to know why my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance unexpectedly reboots or restarts.
Short description
Although unexpected reboots or restarts are rare, there are several reasons they might occur. The following are the most common reasons:
Resolution
There are several actions that 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 its status checks?
Note: If you receive errors when you run AWS CLI commands, then see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.
View system logs
If the instance didn't fail a status check, then the instance might have rebooted due to OS-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.
If the instance fails a status check, you can reboot the instance to retrieve the system logs by using the console output. Review the console output logs to troubleshoot your issue. For more information, see Retrieve the system logs.
- Open the Amazon EC2 console.
- Select Instances, and then choose your instance.
- Choose Instance state, Reboot instance. It might take a few minutes for your instance to reboot.
- Verify that the problem still exists. In some cases, rebooting might resolve the problem.
- When the instance is in the running state, choose Actions, Monitor and troubleshoot, Get system log.
- Review the log that appears on the screen. Find the error listed in the log in Troubleshoot system log errors for Linux-based instances for resolution information.
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
# grep reboot /root/.bash_history
# history | grep -i reboot
# history | grep -i init
# 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 dropdown list, 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.
Related information
Troubleshoot instances with failed status checks
Types of status checks