- Computers & Software
AWS instance ssh connection refused
Steps to fix ssh connection refuse/failure on AWS instance restart
This post assumes that your ssh connectivity was properly configured and you were able to make successful ssh connections to your AWS instance before restarting it.
A pinch of advise: First step to solve a problem is to identify the problem correctly. We often break our heads trying to solve something we don't understand. The time to solve a problem can be drastically reduced when you understand the problem correctly. If you know your problem, there is great likelihood that you may not be the first one facing it. So search over internet with the correct problem description, and most likely you should get your answer.
To understand why ssh connection is refused from AWS, here are few things you should do:
1. On AWS management console > select instance > right click and select "Get System Logs" . This should display what is happening on the OS.
2. On your client machine, try to run ssh command using triple verbose(-vvv) option to understand what is going wrong:
#ssh -vvv -i [your key name].pem ec2-user@[public DNS address of your instance].compute-1.amazonaws.com
If you are getting such error: Network error: Connection timed out or Error connecting to [instance], reason: -> Connection timed out: connect.
Try one of these:
- Check if the server is completely irresponsive: maybe server is running low on cpu/memory causing it to deny any connection
- Check instance security group rules: Your security group may be configured to block the incoming connection on your ssh port(standard port# 22)
- Make sure that you are using the right private key for ssh connection
- Check instance route table for your subnet. You should route ip tables to sends all the traffic destined outside the VPC (0.0.0.0/0) to the Internet gateway for the VPC.
- Check your username for ssh connection, maybe a typo there
So diagnose the problem, understand it and then try to use one of the resolutions.