Why is my nodejs express server connecting to the MongoDB on my local machine and the AWS EC2 Instance - node.js

I have a MongoDB running on my local machine and another MongoDB running on the AWS EC2 instance where my express server and my angularjs web app is installed. That is:
On my local machine (Windows environment), running:
MongoDB
Nodejs Express server
On AWS EC2 instance (ubuntu), running:
MongoDB
Nodejs Express server
AngularJS web app
When I browse my web side running on AWS EC2 instance (using https://ec2_public_ip:3443/home/app/index.html), it retrieves data from the MongoDB running on my local machine. If I shut down the MongoDB and Express server on my local machine, I get Failed to connect to resource error. Why is my express server not connecting to the MongoDB running on AWS?
This is my connection string in the app.js file:
'mongoUrl' : 'mongodb://localhost:27017/myMongodatabase',
I also tried
'mongoUrl' : 'mongodb://0.0.0.0:27017/myMongodatabase',
Both did not work on my AWS instance.
I'm learning to use MongoDB, AWS, Express and now I am confused. Any help is appreciated.

Related

Error connecting to Mongo Atlas

I am working on a nodejs project and using mongoose module I want to connect to Mongo Atlas,
I used
mongoose.connect('mongodb+srv://<USER>:<PASSWORD>#varcv-okhmh.mongodb.net/<DATABAS_NAME>?retryWrites=true');
but I got an error:
failed to connect to server [varcv-shard-00-00-okhmh.mongodb.net:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 35.158.192.211:27017]
I also try to connect via old connection string
mongoose.connect('mongodb://peter:<PASSWORD>#varcv-shard-00-00-okhmh.mongodb.net:27017,varcv-shard-00-01-okhmh.mongodb.net:27017,varcv-shard-00-02-okhmh.mongodb.net:27017/<DATABAS_NAME>?ssl=true&replicaSet=varcv-shard-0&authSource=admin&retryWrites=true');
But I got the same error.
Notes:
everything is working perfectly on my local machine the error is happens when I upload my code to Godaddy Linux Shared hosting.
I am using PM2 to run my server.
I am using Mongo 3.6.5
I am using mongoose 5.1.5

Elasticsearch : connect to a remote server via. SSH (Node JS)

I'm currently using Node's [elasticsearch][1] package. Until now, I connected to the ES instance in the following way.
let esClient = new elasticsearch.Client({
host: '127.0.0.1:9200',
log: 'trace'
});
Now, I've installed ES on a remote Amazon EC2 Linux server by tunneling through SSH using a key file.
I've done the basic ES installation and setup on that server. Tested it as well, and it runs properly.
I've now deployed my Node project on a Server X (EC2 - Ubuntu server).
And Elasticsearch is on Server Y(EC2 - Amazon Linux server).
Apart from specifying the IP in the host parameter what else do I need to connect to ES running on Server Y from Server X?
You have to make sure you have the port (9200) open in Amazon's Security Group settings.

Geth implementation with node JS on elasticbeanstalk enviornment

Hi I am working on node with geth it was running fine on my local machine but when i deploy it on elastic beanstalk server when I execute the geth.start code with require gethoptions i get EACCES error.

How do I run Node Js on my VPS server

I write my server file with node.js and has successfully test in my local , i install node.js and mongoDB plugin on my server , that is windows, but when i type server url instead of my ip in my android app I can't find server and get error server not found
Please help me

Difficulties connecting to socket.io server with Ionic

An overview of my setup:
A socket.io/node server is being hosted/ran on a computer in my local network.
An Ionic app is attempting to connect to the socket.io/node server to send/receive messages.
If I run the app in the browser with 'ionic serve', I am able to connect to the socket.io/node server successfully.
If I run the app in the emulator or on my device, I am only able to connect to the socket.io/node server if I add the -l (livereload) flag (ionic run android -l).
Originally, I hosted the node server on a heroku instance. I had no troubles connecting with this setup from browser, phone, or emulator. I had to switch to running the node server on a local computer so I have access to a local database.
Any ideas what is going on?
I fixed it by adding 'http://' to the beginning of the connection string.
Not sure why Ionic's livereload enabled me to connect without the 'http'

Resources