0
votes

I have tried to install mongodb on linux mint18 but It was got an error Can you help me out What Do i need to do ?

Here is the below an error I have been getting in terminal

MongoDB shell version v4.0.0 connecting to: mongodb://127.0.0.1:27017 2018-07-30T17:30:37.317+0530 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

2
i think you need to start your mongodb server - Harsh Virani

2 Answers

0
votes

You need to start MongoDB server first to connect through Mongo Shell, to server you need to install mongodb server in your system

If you haven't installed mongodb server you can go through MongoDB Server Installation

After installation make sure you have /data/db directory if not run following command

sudo mkdir /data
sudo mkdir /data/db
sudo chmod 777 -R /data

Then you need to start mongodb server by,

sudo service mongod start

If it doesn't work than run following command,

sudo mongod

Now you can connect to mongodb using your mongo shell

mongo

Now you are connected!

0
votes

it's sound like you have to run the mongodb server before try to connect:

bin/mongod is the server executable

bin/mongo is the client shell interface