Ollie
Ollie

Reputation: 1435

ETIMEDOUT error when deploying Node.js app to Elastic Beanstalk

I'm hoping I can get some help with this deployment issue that I'm facing:

I have created an RDS instance and can see it is "Available" by looking at the dashboard. I then use the Elastic Beanstalk CLI to deploy my application and the deployment is successful.

However, when I access the endpoint I am getting a 502 Bad Gateway from nginx. After checking the logs I can see the following error from my Node.js app:

Error: connect ETIMEDOUT x.x.x.x:5432 (ip ommitted)

As per the AWS documentation on this I have tried to assign the auto generated security group from my Elastic Beanstalk instance to my RDS instance, but I am still getting the same error.

Is there something I have misunderstood in the documentation here? I would be very grateful if anyone can point me in the right direction here.

Thank you in advance.

Upvotes: 2

Views: 1096

Answers (1)

Ollie
Ollie

Reputation: 1435

Managed to figure this out after a lot of trial and error. Turns out that it wasn't too tricky.

  1. Go to your EB environment -> Configuration
  2. Click "Edit" next to "Instances"
  3. Note down the security group ID that is selected at the bottom
  4. Create a new security group e.g. "my-eb-instance-rds-access"
  5. Under "Inbound rules" select "Add rule". Choose whichever DB service you are using and it should automatically fill the port. Set source to "Custom" and then click in the search box. Select the security group that your EB instance has that you noted down earlier.
  6. Click "Create security group"
  7. Find your RDS instance and click "Modify"
  8. Scroll down and find "Connectivity". Then select the security group that you just created from the drop down box.
  9. Scroll all the way to the bottom and hit continue. Here I found there to be two options: one that updates the changes immediately and the other that waits for regular scheduled maintenance. I'm no expert but I selected the "immediately" option since the database is not being used in production yet so some downtime was not a problem.
  10. Your EB instance should now be able to connect! This worked for me even after re-deploying.

Disclaimer: I am by no means an expert. This was done purely by trial and error. If anyone has any tips or improvements I'd be happy to hear them and edit the answer.

Upvotes: 2

Related Questions