I'm newbie about node.js and mongodb.
I have already installed mongodb, but I can't connect to mongodb.
This is my error:
Huys-MacBook-Pro:~ huy$ mongo
MongoDB shell version: 2.0.2
connecting to: test
Tue Jan 3 17:12:01 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
If you have created a user and are having trouble authenticating, try the following: Check that you are using the correct username and password for your database user, and that you are connecting to the correct database deployment. Check that you are specifying the correct authSource database in your connection string.
To connect to a MongoDB Server using username and password, you have to use 'username@hostname/dbname'. Where username is the username, password is the password for that user and dbname is the database to which you want to connect to. Note : You can use multiple hostname to connect to with a single command.
In short, the top most causes of this error Mongodb connection refused in Ubuntu are conflicting rules in the server firewall for the MongoDB port or bad settings in mongod. conf file.
MongoDB Cloud Status is Operational.
First of all, check that your data folder exists : mongo on Win. That is
C:\> mkdir \data
C:\> mkdir \data\db
MongoDB is not running, and I have a wild guess that your mistake is this one: Trouble installing mongodb using Homebrew
Create the path /data/db
and then try to start MongoDB again. (run mongod
)
I also ran into this issue today. Mongo had been working fine up until this point. In case you try sudo service mongodb start
and you find out the process is already running (start/running, process xxxx
). The solution is:
Delete the lock file
sudo rm /var/lib/mongodb/mongod.lock
and restart service again
sudo service mongodb start
if you are using windows version then
first run mongod
in one cmd
box
C:\> cd \my_mongo_dir\bin
C:\my_mongo_dir\bin> mongod
leave it open and now again tyep cmd
and do the below
:\> cd \my_mongo_dir\bin
C:\my_mongo_dir\bin> mongo
Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With