0

I am getting 504 Bad Gateway Timeout error in responce but data gets inserted sucessfully to the databse.

Error Message


Code executes perfectly locally with response time within 1.15s but whenever deployed to lambda it start giving this Timeout Error.

Node js Endpoint Route is as Follows

route.post("/Register", async (req, res) => {
  try {
    const user = new userschema({
      Name: req.body.Name,
      Email: req.body.Email,
      UserName: req.body.UserName,
      PhotoUrl: req.body.PhotoUrl,
    });
    await user.save();
    return res.status.send("Created");
  } catch (error) {
    return res.status(500).send("Something Went Wrong");
  }
});

I have Deployed Nodejs backend to aws lambda which is running in a VPC and using mongodb atlas it follow this architecture

enter image description here

I am new to aws so i followed This Youtube Video.

Data gets inserted to mongodb atlas Database sucessfully. So the Vpc Peering conncetion beetween lambda function and Mongodb Atlas must be all right.

Cloudwatch Logs is as Follows

Logs

Logs

Logs

I tried everything i could but still facing this issue.

  • 2
    your lambda is in VPC and making a call to sts. Please make sure you have VPCEndpoint configured for STS. https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_sts_vpce.html – brushtakopo Jan 05 '23 at 16:03
  • I was missing this, now i have configured vpce to service - com.amazonaws.ap-south-1.sts allowed all resources connected all subnets , there is not much resousce to do all this as i am new to aws , do i need to update route table also it has one default route table. @AnthonyB. – Udbhav Vikram Singh Jan 06 '23 at 07:37

0 Answers0