How To Solve 504 Bad Gateway Timeout Error From Aws Api Gateway?

1.4k views Asked by At

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.

0

There are 0 answers