0
votes

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

1

1 Answers

0
votes

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.