Reputation: 91
The default localhost connection refused.
Upvotes: 7
Views: 68522
Reputation: 76
First you need to start MongoDB server. Open VS code terminal or cmd if you have add mongodb on environment variables, and confirm that you are on C:\user\user directory. Then execute: mongodb/bin/mongod.exe --dbpath=/users/user/mongodb-data where /users/user/mongodb-data is your path to mongodb data that you should have.
After that, the mongodb server is running and you can conected from the MongoDB Compass.
Upvotes: 0
Reputation: 41
On Windows, follow the steps below:
Upvotes: 1
Reputation: 31
If you're using windows and getting this error Follow this:
Upvotes: 1
Reputation: 11
This issue arises due to the following reasons:
Solution
Reinstall MongoDB and select complete setup to install all the associated packages of MongoDB.
Type in the Windows search bar for system environment variables, select environment variables and look for the "Path" in the System Variables list.
Click on the path and add a new path for MongoDB by browsing in the system where the MongoDB folder is saved and select the bin folder in the MongoDB directory.
Open cmd and type mongod, this will start MongoDB services.
Now your Mongo Compass should connect and not throw a refused error.
Upvotes: 1
Reputation: 61
Seen so much stuff for Windows but on mac I just ran
brew services start mongodb-community
Upvotes: 6
Reputation: 1
you need to check the status of your localDB ,this command is for ubantu
=>sudo systemctl status mongod
check the status and start your local DB
=>sudo systemctl start mongod
using this command I'm able to connect my local as well as mongo compass.
Upvotes: 0
Reputation: 1
you should create a file for saving data;please take attention to the erro infomation in power shell,follow the infomation and you will solve it. add the file ,for example:"D:/data/db"
Upvotes: 0
Reputation: 370
I'm a Mac user and I hit this error while using MongoDb compass, but I solved this by checking IP address in mongod.config
(which is located by default on Mac at /opt/homebrew/etc/
if you used homebrew to install it) and launching the server using this config file.
To make it sure I set the following config (ip address depending of what you set up in you hosts
file too):
net:
bindIp: 127.0.0.1,0.0.0.0
port: 27017
ipv6: false
Then even if I was in the folder which contains the config file, I had to specify the config file in order to start the mongodb service with the following command line:
mongod --config mongod.config
Then I was able to connect through MongoDb Compass.
Hope this help Mac users who are seeking answers and maybe also Windows users because you might also need to specify that config file even if you are the MongoDb Server folder.
Upvotes: 2
Reputation: 197
Type services in start. open it. search for mongodb there. start/restart the mongodb from services.
Upvotes: 17
Reputation: 19
must you need to run MongoDB server on local? for that, you need to:
run a command on the command prompt. open command prompt goes to a file location like C:\Program Files\MongoDB\Server\4.4\bin
.
type mongod
and press Enter key.
After a few minutes, mongo will be connected. then add path variable to the environment.
Upvotes: 1
Reputation: 61
This message shows that your mongo is disconnected. Therefore you should open your cmd (Windows) Then type `mongod and press Enter key. After a few minutes, mongo will be connected. Then connect through your MongoDB Compass
Upvotes: 3