Unable to connect ECONNREFUSED / Unable to connect ENOTFOUND mongo db vsCode - node.js

I'm trying to connect my mongodb to my vscode and when I try and connect to it using 'mongodb:// it comes up with a connection error. Can anyone help me with this please? 1

you need to try this flow to solve your issue. might be it helps you.
check mongo service is running or not.
if you mongo service is out side of your current machine than you check your IP has access to access your mongo service
check your mongo connection URL is correct.
try to connect your MongoDB using tools like MongoCompass or Robo 3t.
then try in your code for further task

Related

MongoDB no connection could be made because the target machine actively refused it

I was connecting to my MongoDB database installed on my local pc, everything was working fine i was ble to work with mongodb collections when suddenly my pc shutdowned because of loadshedding. After I turned it on again everything was fine except my Mongo Db connection was refused. This was the message being displayed:
cmd mongodb connection error
I think this is caused by firewall, what else it can be? Please help!
Okay so I was able to solve my problem. There was an issue with database path. I don't know why this problem arised because I had worked with this db before my pc went off.
However I was able to resolve this issue:
First locate the directory where your db's are stored. Then in your CLI whichever you are using:
<Your mongodb/server/bin directory>: mongod --dbpath "<your db directory>"

MongoDB stopped working suddenly after days of development

After a few days of developing using Nodejs and MongoDB today I'm getting this error when I want to get into the first page of my app:
MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
And when I try to connect to db using mongodb compass:
Have you verified if mongo is running in the background?
Run mongod in the terminal and see the response, maybe your mongo process is'nt running and then you cant connect to your local mongodb.
I had the same issue and I fixed it.
Go to Services -> search for "MongoDB Server".
Right Click on it and then Click on Start.

connect hostinger DB with nodejs in local

I have created a database in Hostinger and make it remote. But, when I try to connect with my local using nodejs I am getting an error: "ER_ACCESS_DENIED_ERROR" even after using the right username and password.
This is my code below:
Have I done anything wrong? Please help me
This error usually occurs if the credentials are incorrect or the user can not access the database.
Also, In an express app, it is usually better to re-use the database connection instead of connecting to the database on every request.

Connecting to a mongoDB with a TCP prefix on a NodeJS application

I created a NodeJS app that connects with a MongoDB and it seems to work locally.
Now, after hosting the NodeJS application on a remote machine, I am trying to connect to a mongoDB that was already created on that machine. When I print out some of the environment variables, the only one I see of relevance seems to be :
MONGODB_PORT: 'tcp://172.30.204.90:27017',
I tried connecting like I usually do with
mongoose.connect('mongodb://localhost:27017/metadata/')
and replacing it with mongoose.connect('tcp://172.30.204.90:27017/metadata') but I get an error that says my URI needs to start with 'mongodb'.
So I tried replacing it with mongoose.connect('mongodb://172.30.204.90:27017/metadata') and it no longer throws any error. But on the MongoDB side I don't see any new connections happening and my app does not start up on the machine. What should I be putting in the URI?
Your URI should indeed start with mongodb:
mongoose.connect('mongodb://username:password#host:port/database?options...');
See this page for more information: https://docs.mongodb.com/manual/reference/connection-string/
Did you try to connect to the database from cli? Or Telnet to see that connection isn't blocked.

I want to connect openshift mongodb database from my local client tools

I have my premium openshift account
I have all types of access in openshift
I have ssh key & user's credentials
I have MongoVUE & Robomongo & others client tools to open mongodb database.
when I try to open any local mongodb database then its working fine
but I want to directly connect my mongodb database of openshift server to mongoVUE or any else
so I can see which data is in my server database.
I have tried so many times to connect locally but it can connect to openshift but can not connect with mongodb database so please provide some good & exact steps so I can connect it.
I use mongovue also. Just do a
'rhc port-forward '
Then run mongovue using the Mongodb credentials that OPENSHIFT gave you.
Steps.
rhc port-forward <app-name>
Wait a couple of seconds. You then should see something like this.
Then run Mongovue. Add a connection and enter in your Openshift Mongodb credentials like this:
Save, Select your connection, and press connect. It should work.
You should have been given you mongodb credentials when you added the mongodb cartridge. You can also ssh into your app and do a "env" and see your mongodb password and username.
Finally I got perfect tool for it to connect with mongodb with server database in which we can perform all kind of CRUD operations.
we can use Robomongo tool for it which doesn't require paid version to perform CRUD operation.
Robomongo is available here
http://robomongo.org/download.html
mongoVUE requires paid version.
I use Robomongo. Just do a 'rhc port-forward '
Then run Robomongo using the Mongodb credentials that OPENSHIFT gave you.
Steps.
rhc port-forward
Wait a couple of seconds. You then should see something like this.
port forward image
Then run Robomongo. Add a connection and enter in your Openshift Mongodb credentials:

Resources