Error while connecting Mongo to localhost - mongodb

I have Robo 3T-1.3 installed on my ubuntu 16.4 LTS.
It is showing me the following error:
`Cannot connect to the MongoDB at localhost:27017.
Error:
Network is unreachable. Reason: couldn't connect to server localhost:27017, connection attempt failed: SocketException: Error connecting to localhost:27017 (127.0.0.1:27017) :: caused by :: Connection refused`
How to solve it?

Firstly check your mongo status via this command.
sudo systemctl status mongod
OR
You can follow this link.
https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04

Related

MongoDB starting with status error on macOS

I'm using homebrew to initialize mongodb as it follows:
brew services start mongodb-community#5.0
It starts successfully
==> Successfully started mongodb-community (label: homebrew.mxcl.mongodb-community)
However, when I type mongoto run mongodb, I keep getting connection refused:
MongoDB shell version v5.0.2
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:372:17
#(connect):2:6
exception: connect failed
exiting with code 1
So I typed brew services list to check if the mongoDB is up, and it seems it started with an error status:
Name
Status
User
Plist
mongodb-community
error
guilhermemendes
/opt/homebrew/opt/mongodb-community/...
check the following.
if you are using M1 based MacOS then install mongo db (and brew) with Rosetta.
check the IP binding on mongo config
(/usr/local/etc/mongod.conf or /opt/homebrew/etc/mongod.conf)
verify the connection string URI format - Mongo docs - connection-string-uri-format

mongod and mongo both are not running, showing error, can anyone tell whats the problem

MongoDB shell version v4.4.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: No connection could be made because the target machine actively refused it. :
connect#src/mongo/shell/mongo.js:374:17
#(connect):2:6
exception: connect failed
exiting with code 1
I had the same problem. Try starting the mongo shell with:
mongod --dbpath /usr/local/var/mongodb --logpath /usr/local/var/log/mongodb/mongo.log
Details are in the mongoDB docs:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x-tarball/

Mongo failed to start

I am running a mean app, but when I go to run 'mongo', I get the following error:
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
2018-07-25T02:15:24.329-0500 E QUERY [js] Error: couldn't connect to
server 127.0.0.1:27017, connection attempt failed: SocketException: Error
connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
I am sure I am missing something simple here.
mongo is the Mongo shell. It connects to the Mongo daemon, mongod, which isn't running - hence the error.
At the command-line: sudo mongod
Enter your password, and the daemon should start. Now, when you run mongo it should start up ok.

Getting error with mongo commend after install mongodb version 3.6.3

I have facing issues while running mongo commend after successful installation of mongoDB version 3.6.3.
I have run mongo commend and got the following error
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-03-14T18:57:02.928+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-03-14T18:57:02.929+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
Run into the same problem, my error was that I was this command:
sudo mongo service mongod start
Instead of this:
sudo service mongod start
Make sure you run the second one, hopefully that is your error source as well.

How to connect to MongoDB

I am conecting mongo db everyday ,it worked fine but today it troubled me with the below error,can anyone help me please.
MongoDB shell version: 2.6.10
connecting to: test
2017-01-10T14:26:13.073+0530 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2017-01-10T14:26:13.074+0530 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
Run the following command
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart