0

I'm running an application on an EC2 instance (AWS cloud computing solution) that connects to a specific Database address.

When I run the application in my local machine it connects perfectly to the DB.

However, when I run it in the EC2 the connection hangs indefinitely. I've also tried to connect using psql to prove that the error was on the connection and received the "Connection timed out error".

Both my local machine and the EC2 instance are running ubuntu 22.04.

Does anyone have any idea what could be going on?

5
  • 1
    What are the security groups for the isntance? Commented Jul 28, 2022 at 3:49
  • 1
    Where is the database hosted? What is the Outbound Security Group configuration on the EC2 instance? Commented Jul 28, 2022 at 6:05
  • DB is hosted as a RDS instance in AWS. Commented Jul 28, 2022 at 9:56
  • Outbound rules are set to allow all. Inbound traffic is only allowed through SSH in port 22 over TCP Commented Jul 28, 2022 at 9:58
  • Also worth mentioning that connection to other RDS services are completed correctly, the problem is with a specific RDS instance in the same VPC as the EC2 instance Commented Jul 28, 2022 at 10:11

1 Answer 1

1

Both RDS instance and EC2 instance need to be in the same VPC, check your inbound rule of security group of your RDS. It must allow security group of your EC2 instance.

If you configured it to connect through public internet (not recommended) like what you did from local, the inbound rule of RDS need to allow IP of your EC2 instance.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.