Connecting AWS Elastic Beanstalk to MongoDB with a connection string - node.js

I have deployed a Node.JS REST API to AWS Elastic Beanstalk which fetches data via HTTP requests from a MongoDB database (using just the connection string for that, not atlas or anything).
When I run it locally it works fine, but when I try to use the AWS address and run it from there I'm getting a 504 Gateway Time-out error. I don't know what causes this issue and would appreciate some help!

Related

Unable to call Elastic beanstalk APIs via amplify

I am new to AWS. I have my node/express.js backend hosted on the Elastic beanstalk and it's working as per expectation. The express.js APIs communicate with the AWS RDS MySql database and send response accordingly. I have integrated the APIs calls in the React frontend and it is working fine locally. Now I have deployed the React frontend on the amplify and React app is hosted there now. But the API calls to elastic beanstalk are failing on the Amplify with the response "TypeError: Failed to fetch". I have also analyzed the Elastic beanstalk logs but could not find anything there. I wanna know why API calls are working perfectly locally but not on the amplify?
I think the issue is that Elastic Beanstalk requires that the communnication protocol has to be the same for both sender and receiver. So, the solution is to use either HTTP or HTTPS for both Front-End and Back-End.

Connect MongoDB to NodeJS on GAE

I'm running a NodeJS app on GAE and I want to connect to a mongodb cluster on Atlas.
I have white-listed my IP on atlas and established a connection. All work fine on my local machine.
When deployed my app on GAE it could not connect to Atlas since the IP is not white-listed. When I white-listed all IPs on Atlas I could make a connection and everything worked fine as on my local machine
I cannot assign a static-IP to a standard GAE app, therefore I must allow access from anywhere to my cluster on Atlas, which is probably a bad idea.
What would be best solution to work with mongoDB from a GAE standard app?
Any configuration I can make to Atlas? maybe switching to mLab? or any other ideas?
App Engine applications do not have fixed IP addresses. I'm not very familiar with MongoDB Atlas, but it does look like it offers an option to run on GCP and if that runs on a Compute Engine instance what you might be able to do is use the VPC Connector to enable access between your app and your MongoDB setup.

Unable to connect Node app hosted on Heroku with MongoDB Cluster

i am making NodeJS app hosted on heroku and using MongoDB atlas as a backend.When i am sending POST request to app via POSTMAN it is showing:
Error: 503 service unavailable
In my opinion node app is failed to connect with MongoDB atlas cluster.If so then how can i connect it with MongoDB.
THANKS
See Connecting Heroku App to Atlas MongoDB Cloud service, you need to either connect via SSL or whitelist the relevant Heroku IP address ranges for your app.

AWS elastic beanstalk Node.js app is not connecting to Mongodb atlas

I am trying to connect to MongoDB atlas from elastic beanstalk using a Node.js app. on Mongo atlas, I opened the connection publicly for testing reasons (added 0.0.0.0/0 to the whitelist) and AWS security group allows all traffic.
I still can connect to MongoDB atlas from my localhost but not from AWS EBS.
Even I have faced the same issue and it solves by restart the aws elastic beanstalk instance.
Actually, we open do MongoClient.connect once when your app boots up
and reuse the db object. It's not a singleton connection pool each
.connect creates a new connection pool.
So for that purpose, we have to restart the instance and it will work but for the security purpose, we can try VPC Peering for MongoDB Atlas.
Hope this will help some one else..!!

setting up aws sdk for node.js keeps returning 502

Hi I followed the tutorial here to set up a node.js application with aws sdk on elastic beanstalk http://aws.amazon.com/developers/getting-started/nodejs/
However, I keep getting this when I upload to elastic beanstalk.
502 Bad Gateway
nginx/1.4.7
I notice when I upload a normal node.js file with requiring aws-sdk, it works.
Why is this?

Resources