In previous articles, I have mentioned how to Resize or Upgrade AWS EC2 Instance and What is EC2 (Elastic Compute Cloud) in AWS but now in this article, I have provided step by step procedure to reboot or restart AWS EC2 Instance using AWS Console or using CLI.
There can be situtaion in your EC2 Instance, when you would like to reboot or restart it.
For example, I had some issue on AWS EC2 Instance, I wasn't able to connect to it using RDP until I reboot the system, so in the cases like this we would have to restart or reboot AWS EC2 Instance.
Rebooting an instance is like rebooting a PC, so let's take a look on few way of restarting or rebooting AWS EC2 Instance.
Reboot EC2 Instance using AWS Console
For rebooting AWS EC2 instance using the console, you need to follow below given steps:
- Login into your AWS EC2 Console.
- Navigate to "Instances" (From left-pane) and Select instance which you want to reboot or restart
- Right-click on it and then select "Reboot"
- A pop-up will appear, Click 'Yes, Reboot' and confirm.
That's it, now your EC2 will restart in few minutes (1-2 minutes most of the time), during this time-frame, you may not able to access website uploaded on that instance, but if you are using caching using Cloudflare CDN or using Amazon CloudFront content delivery network (CDN), then it show cached pages of website to user.
Restart or reboot AWS Instance using CLI
You can also use Command line Interface tool to reboot or restart AWS instance.
For example, below command will reboot instance, but will not return any success message
aws ec2 reboot-instances --instance-ids i-1234567890abcdef5
Reboot AWS using Powershell
First, we will need AWS key and credentials for this, here are the steps to follow
- Go to your account, select Security Credentials and create an AWS access key and secret key.
- Open Power-Shell for AWS, which will ask for your AWS Access Key and Secret Key.
- If Power-Shell doesn't prompt for keys go to "C:\Users\Administrator\AppData\Local\AWSToolkit" and delete the Registered Account Jsonfile and open Power-Shell again.
- Now get your instance id by using this URL from EC2 instance
http://188.8.131.52/latest/meta-data/instance-id // here 184.108.40.206 is my private ip for instance?
- Now from powershell give below command
Restart-EC2Instance -InstanceId i-12345678?
That's it, it will reboot your AWS Instance.
You may also like to read: