Can not connect with AWS : Connection time out error - amazon-web-services

I am using ssh command to connect with AWS instance :
ssh -i ./abcd.pem ubuntu#ec2-**-***-**-**.us-east-2.compute.amazonaws.com
These are my inbound rules :
Earlier It was working well suddenly it started giving this error I have also tried with different networks still the same problem.

Assuming that AWS hasn't stopped you from connecting because you're out of money, the simplest explanation is that your host is simply unstable and needs to be rebooted.

Stop your instance and start again, try to connect by new IP address, if still not works, you have the Internet connection problem.

Related

unable to connect to the aws ec2 ubuntu instance

Getting error
failed to connect to your instance,
Previously it was running perfectly,
Could you please tell me, why is it not connecting?
my instance is running, occurring this error
failed to connect to your instance, error establishing ssh connection to your instance ec2
Thanks.
Use public and private i-e ppk,pem keys to connect the instance.
Is it possible to post screenshots of error that you are facing? It will give more clear idea. Few suggestions -
If in Security group, for port 22 you have used My ip, try removing it & again give my ip. As home router restarts, new ip is assigned to it.
Check if correct key is used ie pem or ppk

AWS Connection timeout + EC2 Instance Connect not working

I tried to connect to a running ec2 instance with my usual settings, it returns
ssh: connect to host ec2 port 22: Connection timed out
I tried to connect with the built-in "EC2 Instance Connect", to connect directly from the browser with the AWS account, it returns
There was a problem setting up the instance connection An error
occurred and we were unable to connect or stay connected to your
instance. If this instance has just started up, try again in a minute
or two.
The instance was running for weeks, I am the only user with access to the AWS account and the SSH Keys and I didn t change any setting in the last ~3 weeks or restarted it
1st the timeout started ~1 week ago, nand then without any other change, my website (wordpress) suddenly started to show a database connection error (the database in inside the EC2 instance as well)
What I used to connect :
Either
ssh -i "Keys.pem" ec2-user#ec2-[public ip].eu-west-3.compute.amazonaws.com
Or
ssh ec2-user#[public ip] -i "Keys.pem"
Both show the same error. I used the first one several weeks ago and it used to work well
This timeout will be caused by invalid security group rules.
Ensure that the security group rules attached to your instance allow inbound access from the source IP address you're trying to SSH from, the database connection may also be related to this.
If you're connecting using a dynamic public IP address to SSH to your host, you will need to adjust this every time your IP address changes. It might be more appropriate to setup a VPN so that you can connect privately to your host.

AWS Ec2 "Connection refused"

I used to be able to connect to my ec2 instance but suddenly I am no longer able to and I do not know why. My security group is the same, allowing ssh from anywhere. I have some information below regarding the errors that I am getting. Please can someone advise?
From FileZilla I am getting:
Error: ssh_init: nodename nor servname provided, or not known
Error: Could not connect to server
From the terminal I am just getting:
ssh: connect to host ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com port 22: Connection refused
i have the same issue i did the following troubleshooting steps and it still gives the same
ssh: connect to host [my public DNS] port 22: Connection refused
i checked the key ".pem" file and its correct on the right directory
no code edits as it used to work fine last night and suddenly this error appeared
i went to the AWS console, selected the instance , and clicked on connect and copied the SSH command to make sure that no typos , and the command is correct
i tried with -v , still same issue.
tried to reboot the instance , no progress
stop then start the instance , no progress
tried to detach the volum and re attach the volum back , no progress
i changed the instance type from t2.micro to t2.small , no progress
checked the security group , port 22 is assigned to all IPs and no problem with the security group at all as it used to work fine
tried from different computers from different networks, same issue
created new instance , i can access the new one but cant ssh to the old one still
my best guess is that the ssh daemon is not enabled but how to access it if i cant ssh to the instance

AWS: Cannot connect to Amazon instance

I had been trying to establish a MongoDB database with an exposed REST API (through Crest, then Sleepy Mongoose), but neither of these had been working. I tried to do a minimal sanity test of "Can I connect to that AWS machine or not?", so here's what I tried:
1) I set up a new Amazon instance (Ubuntu 14.04), and I made sure that all incoming TCP connections were accepted.
2) I tried running sudo python -m SimpleHTTPServer 80.
3) This worked when logged into the machine and doing curl http://localhost:80/ and curl http://XX.XX.XX.XX:80/ (the machine's IP address substituted of course). However, on my local machine, the command just timed out.
I'm really looking forward to any guidance here, so I can hopefully go back to what I was originally doing (MongoDB, exposing a REST API, etc.). Really thankful for any suggestions since this has been driving me crazy!!
This is probably a security group issue.
When doing the curl http://XX.XX.XX.XX:80/ on the machine itself, did you try the internal ip (172.x.x.x / 10.x.x.x / 192.x.x.x) or the external ip?
Also, does the machine have an external ip assigned? (I'm guessing it does, otherwise ssh'ing to it would only be possible from another machine in the same subnet.)
Go to the AWS console, open the instance details and check the instance's security groups. Is port 80 open for the world (0.0.0.0/0) ?

Connection getting refused to socket.io server on Amazon EC2

I have set up a a micro EC2 instance on AWS. Currently, I am using the free tier in Oregon. There are two problems which I am facing.
When I try to SSH the instance using the public DNS, it says host does not exist but when I try conencting it using the public IP, it connects to it. What setting is needed to use the public DNS ?
I have opened the SSH client using the IP address. I want to set up my application which needs Node.js and MongoDB. I installed Node.js using this
Next I installed MongoDB using this
Then I connected to my instance using Filezilla and uploaded my code to it. I then start my node application which uses socket.io.
When I try to connect to socket.io server using web browser, I get a message which says connection refused "error 111". I have opened TCP port 80 in instance's security groups. In iptables, I have forwarded port 80 to 8080, but still it does not work. I have also checked that the firewall is disabled in ec2. Kindly help me to resolve this issue.
Did you check if all of the necessary ports are open on Amazon Security Policy?
What you can do is to allow all traffic on Amazon Security Policy for test and see if the connection goes well or not.
You might also check if you need access DB from outside. In that case, you also have to open the mongodb port and setup mongodb correctly as well.
Other tools that might useful to test firewall and connection issue will be tcpdump and syslog file
For the dns issue, did you try to nslookup on that name and see if the IP shown matches your server IP?
As Amazon gives a long DNS hostname for the server, I always use my own domain name. It's much easier.
example : ec2.domainname.com, which points to the Amazon IP address
Hope that help.
My problem is resolved now..
For the DNS issue, earlier I needed proxy to access internet, so I guess the DNS name was not getting resolved. When I tried using proxy free internet, I was able to ssh using public DNS.
And regarding connection to socket.io, I used port 8080 instead of 80 and used "sudo node main.js" to run my node file. Now I am able to connect to the socket.io server and MongoDB.
Another thing which I want to ask is that would running the node file with sudo rights create some security issue ?
Thanks for the answer! That also worked for me. I had the same problem trying to connect through sockets (http://myipaddress:3000) to a node.js server, i tried opening ports on the actual ec2 instance and disabling the firewall through SSH but nothing worked. Had to go to Security Groups on the ec2 console and open a new inbound tcp rule enabling that port